473,382 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Design a new library over existing c codes. What is the best way?

Hi there,

I had a scenario here.

I had many tonnes of C codes in my office. Each C codes are used in low level stuff. Like connecting to smart card readers or even the OS itself.

I was being hired to push .NET into it and fully object oriented.

I had some questions to ask.

1) Is C# is the right way to do a rewrite over those existing C codes. I have to use platform invocation all the way, and do some marshalling. Just i seen too many p/invoke, and starts to wonder whether it will cause performance breakdown.

2) If i use C++.NET, i heard i can call directly from the windows.h. in C#, i need to use dllimport can direct call into kernel32.dll or winscard.dll. Quite tough.

3) I am not calling the C dll, if i do, i don't fit my job requirements.

4) Is C++.NET or C#, which one is the best way to create this whole new design of the library? I had the design planned using some design patterns?

5) In C, we can use pointers, but in C# i am preventing myself to use unsafe. Better stick on the safe side. Just too many pointers in there, and it takes time to understand the code. I am not that strong in C, only can read but cannot code it.

Please share some time to shed some comments for me. Thanks.
--
Regards,
Chua Wen Ching :)
Nov 16 '05 #1
1 1237
Hi Chua Wen Ching,

First off, take a look at the Facade pattern for places where you are using
P/Invoke to windows level services. Create a couple of facades for lower
level services so that you can call them from you code without dealing with
the mechanics. I do not know if P/Invoke is slower or not (perhaps some
other folks know). However, you have been assigned to do this, so don't
sweat it too much. On the other hand, if there's some code that needs to
make dozens of calls in a row, and if there is a performance penalty, you
may want to leave some of the C code in place to do the Windows API work,
and just make a single P/Invoke to your old C code.

As for which is better:C++.NET or C#: don't ask about efficiency... ask
about what languages you and your company want to support! Every line of
code has to be maintained. One language is better for your company.

Use design patterns. I encourage that. That's the best way to get to a
good OO design.

Whenever I have to rewrite code that I don't know, I try to start by
learning what the code is trying to accomplish, and then look for the places
where the code catches errors or handles exceptions. Start with intent.
(There's an entire field of research called "intentional programming" based
on this concept).

I hope this helps,
--- Nick

"Chua Wen Ching" <ch************@nospam.hotmail.com> wrote in message
news:8D**********************************@microsof t.com...
Hi there,

I had a scenario here.

I had many tonnes of C codes in my office. Each C codes are used in low level stuff. Like connecting to smart card readers or even the OS itself.
I was being hired to push .NET into it and fully object oriented.

I had some questions to ask.

1) Is C# is the right way to do a rewrite over those existing C codes. I have to use platform invocation all the way, and do some marshalling. Just i
seen too many p/invoke, and starts to wonder whether it will cause
performance breakdown.
2) If i use C++.NET, i heard i can call directly from the windows.h. in C#, i need to use dllimport can direct call into kernel32.dll or
winscard.dll. Quite tough.
3) I am not calling the C dll, if i do, i don't fit my job requirements.

4) Is C++.NET or C#, which one is the best way to create this whole new design of the library? I had the design planned using some design patterns?
5) In C, we can use pointers, but in C# i am preventing myself to use unsafe. Better stick on the safe side. Just too many pointers in there, and
it takes time to understand the code. I am not that strong in C, only can
read but cannot code it.
Please share some time to shed some comments for me. Thanks.
--
Regards,
Chua Wen Ching :)

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Eric Veltman | last post by:
Hello everyone, I've posted this question before, but got no answer, so I'll try to reformulate the question, maybe it helps :-) By the way, this is not intended as the start of an ASP.NET...
3
by: c# beginner | last post by:
we are trying to standardize return codes across our .NET applications (that are soon to be developed.) What is the best practice for standardizing return codes? I know of only the following...
4
by: Luis Esteban Valencia | last post by:
Hello. Can somebody recomend me books of design patterns in c# and best practices too.
10
by: Mr Newbie | last post by:
Does anyone have any recommendations for a really good book, or web site article on design of N-Tier systems using .NET -- Best Regards The Inimitable Mr Newbie º¿º
1
by: John | last post by:
I took an hour or two to browse for articles, sites, and books that discuss practical patterns and best practices for XML Web Services in .NET. Essentially, I've gone through the Quick Starts <a...
7
by: shrini | last post by:
Friends. I need a inventory software in php for my friend's general merchant shop. please recommand which one is best. In sourceforde and freshmeat, i find a lot. but, unable to try many. ...
23
by: JoeC | last post by:
I am a self taught programmer and I have figured out most syntax but desigining my programs is a challenge. I realize that there are many ways to design a program but what are some good rules to...
1
by: MrNobody | last post by:
I'm going to be creating shapes in a OnPaint method of an extended Panel object, and I need mouse event functionality (onClick, onMouseOver) that kind of stuff... what's the best way to go about...
2
by: Paulo Matos | last post by:
Hi all, Guess I wish to do some parsing for a calculator which might include rational numbers. So I can have integers (sequence of digits possibly started by -) and rationals (two integers...
7
by: anderszvensson | last post by:
Hi, I have a problem that I’ve tried to get help for before, but I wasn’t able to solve it then, so I’m trying to simplify the problem now to see if I can get some more concrete help with this...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.