|
-
Feb 4th, 2009, 06:38 PM
#1
Thread Starter
Frenzied Member
[2.0] Learning more about OOP?
Is there a good website with specific concepts of OOP? I find myself constantly not taking advantage of OOP, mostly because I learned a lot of my programming through Assmebly/C.
So does anyone have any good sites?
On a side note, are there any good sites on helping with organizing code and guis?
-
Feb 5th, 2009, 10:08 AM
#2
Frenzied Member
Re: [2.0] Learning more about OOP?
To be honest I have never come across a good OOP design document on its own. There are different levels of OOP, some people don't use it enough, some people use it well to much. Generally I tend to put my project on paper and group it into classes from their. Let me give you an example:
I am working on a code Highlighter (See My Blog in my sig). Their are two main components to this blog. The first is the GUI and the second is all the code involved with formatting the source code and highlighting it. Lets talk about the gui first.
The GUI is made up of a main form which has 1 text box, two combo boxes and a button. The user enters the code in the text box. Then selects the source type (VB,C#,Xaml) from the first combo box and the output type (BBCode, HTML) from the second box, finally when the button is pressed the magic happens and the output is placed on a second form with one textbox and a close button.
Now I could put all the functionality for highlighting in the button command but GUI seperation is a must as this project may be used for a web/silverlight version. So we make a new class called hEngine. This class will contain all the information regarding the highlighting. The only other issue with the gui is how to tell what goes in the combobox as only the engine knows what it highlights. So what we do is make 2 methods in the class 1 to get a list of all the source options and one to get the output options for each source option. then we can simply call the GetSourceTypes() and GetOutputTypes() which return an array of strings, the GUI will handle what to do with these strings.
The basic idea is a gui should never proccess information, only present it. Now this of course extends to transforming the information to present it better, for instance while GetSourceTypes returns a string array the GUI would have code to convert this to something like a comboItem (a wpf control) or a listitem or what ever. So you GUI always sends and recieves simple data, remember that!
Some people disagree with this and would say that the hEngine class should return strings, listitems AND combobox items. This is impractical though because you want to make the engine reusable and to do this you need to work with only simple data, if you start returning complex types you limit reuse.
As for the class, while I am still designing it basicly everything else will go in their as it is all related. I do sometimes use partial classes to keep classes easy to read, especially because I make heavy use of enum's an tend to keep them declared in their own partial. Some people would further abstract but too much abstraction is a bad thing. Everything is related in this class so it is best to keep it together. On the other hand the class is not really related to the GUI as a GUI is only a means to show data and therefore can differ witout affecting core functionality.
One thing I will say is try not to hard code data into classes, if a class is too small for database use XML. For the couple of hours it takes to write an XML file and some methods to work on it the return of time investment is a class that can work with changes to data without altering the class structure itself.
Regarding reading, andrew trolsen has a book on apress called pro c# and the 3.5 framework which is amazing. Its a really good reference and half the book is dedicated to OOP features. Its easy to read and contains a wealth of information 
Wow, im tired after that. Remember keep half an eye on my blog as I will be explaining things like this in the context of projects I make
-
Feb 5th, 2009, 10:11 AM
#3
Thread Starter
Frenzied Member
Re: [2.0] Learning more about OOP?
Thank you for taking the time to post that. I will look for Andrew's book and see about buying it.
I guess it boils down to the person. Every person writes code differently.
-
Feb 5th, 2009, 10:17 AM
#4
Member
Re: [2.0] Learning more about OOP?
I want to thank you for taking the time to post that too. I have recently realized that there's still a WHOLE LOT of procedural-ness in my thought processes regarding coding. I get the general concepts of OOP but putting into practice can be difficult. Thanks for helping me understand it a bit better.
Hypermommy
No cool tagline or anything. Haven't thought of one yet.
-
Feb 5th, 2009, 10:24 AM
#5
Frenzied Member
Re: [2.0] Learning more about OOP?
No bother guys remember that there is no such thing as true OOP, think of it as just grouping related sections of procedural code into little boxes that work together. Ok that is over simplifing it but it does help to wrap your head around it. This is the book: http://www.apress.com/book/view/9781590598849 keep away from anything by christian gross they are filled with nonsense at code that is incomplete and over complicated.
-
Feb 5th, 2009, 02:06 PM
#6
Re: [2.0] Learning more about OOP?
It's usually best to get an existing project and have a look at it; or post your project and get others to rip it to pieces.
-
Feb 5th, 2009, 02:37 PM
#7
Re: [2.0] Learning more about OOP?
The concepts of OOP can be found anywhere online, and arent that hard to learn (altought that might be rather subjective). However it might not be apparent when and how to use it the OOP concepts (polymorphism etc). I would recommend a good book in OOP design patterns, such as this one: Design Patterns: Elements of Reusable Object-Oriented Software
-
Feb 5th, 2009, 04:22 PM
#8
Frenzied Member
Re: [2.0] Learning more about OOP?
Actually now that I think about it Code Complete 2 is a great book and while it doesn't talk about OO from beginning to end it does talk about good software design!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|