PDA

Click to See Complete Forum and Search --> : [RESOLVED] transitioning to OOP methodology experiences


layne
Jul 6th, 2008, 03:45 PM
I happen to change my code from traditional vb 6 to a little bit of .net, and so It took me a few weeks to eventually change some parts of it, being the only developer here (without oop experience), so I am still struggling, any good book out there that you can suggest where there are a lot of code examples from analysis to programming?


thanks

DeanMc
Jul 7th, 2008, 11:17 AM
A great book for coding concepts is Code Complete 2. While not specifically OO orientated this book does provide many useful code examples and general good practice rules for coding. The examples are in Visual Basic and Java I believe so it should be easy to follow.

layne
Jul 7th, 2008, 07:32 PM
Have you ever had any experience inheriting a working system from another developer which you tried to get your head into that code but not quite understand it? Well, that is my dilemma now, I need to support this new .net application which has soooo many classes creating from different classes which creates objects from different classes and so on, but the output is just 2 web methods that calls some stored procedure?

wow, i guess i'm in trouble now...

DeanMc
Jul 8th, 2008, 07:45 AM
Unfortunately there is no book that will help you with that. That is basicly a common mistake of may developers taking OO design too literaly. My suggestion would be if it is plausible to rewrite to code as you may end up spending more time trying to figure out how to read the old code than you would trying to write the new code.

RhinoBull
Jul 8th, 2008, 08:41 AM
I happen to change my code from traditional vb 6 to a little bit of .net ...
Not sure what that mean, though:

- are you migrating your VB6 app to VB.Net?
- or you are trying to use some of OOP in VB6?

Unfortunately there is no book that will help you with that...
There are plenty of books (great, good and not so...) - here are two that are great:

- OOP in VB6
Programming Microsoft Visual Basic 6.0 by Francesco Balena (http://www.amazon.com/Programming-Microsoft-Visual-Basic-6-0/dp/0735605580/ref=sr_1_4?ie=UTF8&s=books&qid=1215522200&sr=1-4)

- OOP in VB.Net
Programming Microsoft Visual Basic .NET by Francesco Balena (http://www.amazon.com/Programming-Microsoft-Visual-Basic-Reference/dp/0735613753/ref=sr_1_5?ie=UTF8&s=books&qid=1215522853&sr=1-5)

-----------------------------------------------------------------------

However, OOP was never considered as best programming approach - it does have lots pros but just as many cons.
One of the major con is OOP has tremendus overhead (in VB.Net every data type is an object so it makes even worst) so if not properly used your app may blow (basically it eventually eat up your system's memory).
In VB6 on the other hand Strings, Integers, etc data types are not objects and that means none of them will require as much memory as similar data types in VB.Net.
It is up to programmer (or perhaps architect) to decide which way to follow or find best compromise.
Is it possible to avoid using objects in these days? Most probably not but it doesn't mean that someone is required either - let's leave that to purists only...

Regards.

DeanMc
Jul 8th, 2008, 08:45 AM
@ RhinoBull: None of those books will teach the OP how to maintain his code. The issue is not that the code takes the OO approach, rather the issue is the original author of the code did not know enough about OO to make production code that was elegant and easy to handle.

RhinoBull
Jul 8th, 2008, 10:31 AM
... to make production code that was elegant and easy to handle.
Vast majority of code out there is just like that - you have to learn how to read somebody else's code and develop your own style just for purpose and (as already mentioned) there is no book to teach you to do that.
It takes time to develop your coding style that is easy to read and maintain, it may take a lifetime [without success] for someone however.
OOP or not shouldn't really matter ...

Look at some samples that are easy for you to read and perhaps learn from any of them - we have of plenty of those arround here.

Good luck.

Dnereb
Jul 8th, 2008, 11:19 AM
To support RhinoBulls litrature suggestion

Programming Microsoft Visual Basic 6.0 by Francesco Balena

Was my Bible while programming VB6.0 and it made a big difference because it made the step to VB.Net easier

- OOP in VB.Net
Programming Microsoft Visual Basic .NET 2003 by Francesco Balena

Is My bible today, I Just Peak in to the 2005 edition for new things because the 2003 version is setup like the VB6.0 version and the 2005 isn't

mendhak
Jul 8th, 2008, 01:48 PM
Remember not to go for a class-by-class conversion. Look at the bigger picture and if you have a good understanding of the application, redesign it.

layne
Jul 8th, 2008, 02:59 PM
Rhino, what I mean is, i've created an app using .net but without inheritance and class objects, just plain procedural, calling methods within methods and stuff like that. Now, I've tried re-writing the code to have some sort of 'Class' and i've created objects and called methods of those objects, so my program is somewhat OOP now, but not 100%.
Now, this new app that was turned over to me uses purely OOP without inheritance but using so many namespaces from the same solution, and so many classes that creates objects, but those created objects have the data type of another class which is linked to another class, etc, oh well!

RhinoBull
Jul 8th, 2008, 03:56 PM
... my program is somewhat OOP now, but not 100%...
There is asolutely nothing wrong with that - as I said 100% is for purists.

... but using so many namespaces from the same solution ...
Imaging creating a class with say few dozens of properties.
Now, you need to use just a few of them but you still need to create new instance of that class first.
So, you'll end up with allocating memory for the entire class instead of what's necessary for say 2 integers.
Is that a waste? IMHO it is. 100% OOP is affecting performance - under sircumstances a lot.
If you want to learn OOP to full extent then use one of those books and create some test app for your own purpose but I suggest not to go crazy about it in any of your production applications.

layne
Jul 8th, 2008, 08:04 PM
yep, thanks, will do.