|
Roger Wright wrote: The architecture is critical, and that's what I was asking about.
Couple things
Roger Wright wrote: user select one of the main functions - Add, Edit, Move, Service - from the main form
User selects from Menus and toolbars, not forms.
Roger Wright wrote: The next shot was to create forms for each function and equipment type, then walk through them depending on user selections, and updating the database through the final form in each sequence. Not only is that wasteful (having all those forms lurking about whether needed or not) but it just strikes me as awful design. There ought to be a single point of control for the data access, a separate layer that is common to all functions.
The problem with that section is that you are coupling the UI design to the Code design. This is not correct. Arrive at a UI design from considering usability. The problems with code design are not related to UI design.
Now let's talk about the last part of that section.
Roger Wright wrote: There ought to be a single point of control for the data access, a separate layer that is common to all functions.
Yes, that and many other Software Design Patterns are already common knowledge. This statement can only have us conclude that you are not yet studied enough in design and patterns to understand the solutions to these problems. Furthermore trying to cover all that ground in an internet forum reply is not an appropriate reaction.
My advice is that you stop development and continue with your studies of design and patterns. As you learn well known design principles and patterns you will recognize some of them as solutions to your current problems. Well at least that's how it works for me.
In case you have not seen these folks ( there are many others as well) here is where they share their expertise:
Martin Fowler[^]
Ward Cunningham[^]
|
|
|
|
|
It seems not so complicated a project for you to design for. Now that you have three types of equipment, why not design three different forms for each type?It's no need to construct a perfect design in one project,at least not for this one ,right?To achieve your goal is OK,right?
Regards,
Dealon
Impossible is nothing!
|
|
|
|
|
Hello All,
Just wanting to ask about class methods in OOP / 3 tier layers.
How do you determine where the methods reside in a class, with reference to the Business Logic Layer.
I am very confused about this.
Any help would be great. Thanks
|
|
|
|
|
CrimeanTurtle2008 wrote: I am very confused about this.
Then you need to be reading materials on the subjects rather than posting things in internet forums. I guarantee your progress will be like 10 fold faster.
|
|
|
|
|
Hello,
I'm making an email client as a homework.
Its supposed to have multiple account support, contacts, etc.
But im in a discussion with another person about an OOP thing,
We have the class "Message", and it contains the fields from, to, bcc, cc, and of course others, but this problem is focused on those fields.
Considering that:
-A message can contain multiple emails in the to, bcc, and cc field.
-For whatever reasons we have the classes Account and Contact
One approach:
To have all these fields of type string, that is:
from : string
to : List< string >
bcc : List< string >
cc : List< string >
Second approach:
To have the class Person (with the fields name and email) which is a generalization of Account and Contact, that is:
Account extends Person
Contact extends Person
And in the class Message, to have these fields of type Person, that is:
from : Person
to : List< person >
bcc : List< person >
cc : List< person >
I would go for the second approach but the other person insists on going with the 1st choice, and I don't know how to convince it, and to convince myself that i'm right.
SORRY BAD ENGLISH!
|
|
|
|
|
Wouldn't the Person class support multiple email addresses too? I have several.
How about an IAddress interface (I have no idea what it may contain) which EmailAddress (and others) implements.
Person can then have a List<IAddress> and some instances of Person may contain instances of EmailAddress and an email message will use List<EmailAddress>
You may also want to look at the classes in System.Net
|
|
|
|
|
So the big question has to be: Why do you think your approach is right? If you can't convince yourself its the one to go with, you'll have a job convincing someone else. To make it easier to come up with an answer use just the 'to' as an example as the other lines, bcc, cc etc are similar. What do you get, if anything, using Person that you don't get using String? Or conversly: What do you get using String that you don't get using Person? If there is a difference here, Does the user of the email system you are designing want whatever benifits that difference brings?
|
|
|
|
|
What do I get using Person that I don't get using String:
That future operations will be easier because of treating with an object person than a string, for example searching, or showing the person info (lets say a picture, or the fullname, or whatever) when reading the message. Of course I can do that too if those fields are strings but I think i would have more hardcoding instead...
Am i right? also conceptually I would have object connections between a person and a contact, which wouldnt be that explicit if those fields where strings
Thats why I defend the Person class
|
|
|
|
|
Hi,
That future operations will be easier because of treating with an object person than a string..
Leaving aside whether these future operation will be easier this way or not for a second, it's homework - you've only got a limited amount of time to design and code a limited amount of features. So you really need to decide what those features are before coding i.e What are you going to do. Only after that, decide how to do it. Just like any Project - homework or otherwise.
For example searching, or showing the person info (lets say a picture, or the fullname, or whatever) when reading the message...
Searching for what? You have do decide befor starting the coding.
Are you going to want to display a picture for every email you read? You won't have one for most of the spam you get!
Do you have to display the fullname of every email you read? Again a lot is junk so you won't be able to for everyone
'Or whatever': The 'whatever' bits derail lots of projects because nobody has decided what features are being aimed at, they've just sat down and started coding.
A message can contain multiple emails in the to, bcc, and cc field
Decide exactly what a message is. Is it an email (rather than multiple emails) with multiple addresses rather than multiple emails?
Of course I can do that too if those fields are strings but I think i would have more hardcoding instead...
to be honest I'd say its hard to tell how much coding will be needed either way at this stage. Though I see what your point is.
Am i right? also conceptually I would have object connections between a person and a contact, which wouldnt be that explicit if those fields where strings
One of the biggest slip-ups I see, and which I made, when starting OOP is to have all the objects dependant upon (know about) one another. Object A knows about object B which knows about C, D, E etc and when you want to make a little change to one it affects them all and gets complicated.
Get used to thinking what the User wants. If the User wants stuff like being able to hover their mouse over an address in an email and have details pop up, it may be that being able to link that address to the Person object will be handy.
I'd think of another object or just code that combines other objects - The-email-editor as well. This could do the hard work of linking addresses to Persons, and could keep the Message and Person objects separate.
Sorry if I'm not saying Yes/No you should use the Person class, but its your homework after all and I'm just trying to make you think of some of the reasons why you would decide Yes or No. One definite thing is, that by being able to code Person without knowing about the design/code of Message and vice-vera you have an advantage.
|
|
|
|
|
Sorry if I'm not saying Yes/No you should use the Person class, but its your homework after all and I'm just trying to make you think of some of the reasons why you would decide Yes or No. One definite thing is, that by being able to code Person without knowing about the design/code of Message and vice-vera you have an advantage.
Thanks for replying.
I think you summarize my whole point of view in your last paragraph.
About what a message is, maybe I messed up things when saying "a message can contain multiple emails in the to, bcc, cc fields", i was referring to "multiple addresses".
|
|
|
|
|
Quake2Player wrote: What do I get using Person that I don't get using String:
I don't know, how are we supposed to know that, we don't have your requirements nor your design documentation. You know things like Use Cases and CRC cards.
You say you are a student, do they have you learnCRC Cards[^]? If not you should.
Notice item #3 "The responsibilities of the class."
Responsibility is key in determining design and the answer to your question "what do I get".
|
|
|
|
|
For not making another topic, I have an encapsulation debate with myself:
Account contains List< Contact > and List< ContactGroup >, and methods to manage these..
How should I DECIDE if I should encapsulate all the contacts classes and methods in lets say an AddressBook class?
The same for other things contained in Account, like all concerning Messages: List< Labels >,List< Messages >, List< MessageThread > and methods..
My great question would be that if I have a lot of encapsulation, then I would have a lot of inbetween methods, from the main application to the object itself, like...
Application.AddLabelToMessage()
calling Account.AddLabelToMessage(msg, label)
calling MessageManagerOrSomething.AddLabelToMessage(msg, label)
calling certain Label as Label.AddMessage(msg)
Please have patience, i'm learning to model well (I know these can be done either way)
Again sorry bad eng.
|
|
|
|
|
How should I DECIDE if I should encapsulate all the contacts classes and methods in lets say an AddressBook class?
Does the word ('AddressBook' in this case) come up often (preceded by 'the') when you talk or think about the design and how to do it? If so it's probably a good contender to be an object. Then, consider if you can come up with messages (methods) such as Set...., Get....., Do....., that you would use on this object to have it do things.
Should one class contain other classes?
Ask: "Does Class1 have a Class2 OR Is Class1 a type of Class2, if its the first one, Class 1 should contain Class2.
Consider your: List<messages>, what happens if near the end of your coding you decide to change to, say vector<messages> or String Messages[50]. If you've written a class CMessages with methods, say, GetMessage(...) and AddMessage(..) which encapsulate this, then it's no problem. If youve used list here there and everywhere in the code it can be a real problem to change them all.
a lot of inbetween methods?
Being able to call Application.AddLabelToMessage(...) is probably better than needing to use four or five lines to get one object, then another from that, then another from that and finally to call, say, MsgHeader.AddLabel. You don't want to bother low level objects like, say, MsgHeader objects at a high level. Just calling AddLableToMessage hides the complication that (may) be in the method from the caller. Encapsulation is all about hiding complication.
In the end, does it feel right? This may take experience but if it feels right, go for it.
|
|
|
|
|
*i am a starter , trying to learn the GOF patterns.
i am using vb.net , understand c#. still wan't a job in holland as starter in vb.net .
i am a person who doesn't want to have full blown solutions , i want to learn by coding , what is happening deep inside the logic.
*i am trying to serialize my tree , filled with nodes that work like groups(with nodes) / transforms(leaf) / 3d-meshes(boxes/ball/other primitives) in a world node.
yes i am trying to share my servers '3d world' with my clients.
*but when i try to serialize my tree to xml , i end up with errors like :
-my leaf objects cannot have children.
-xml serializer cannot recognize what kind of object a child is.
*i am now trying to build my personal serializer , that breaks up my tree into a array of objects , and then seperately serializes each object.
*in the future i want to grasp the idea of sending the whole world state and the delta-state (difference in worlds , inbetween two times).
*did anybody found some examples. or know some ideas how to help me ?
Jarno Burger
Video Jockey
|
|
|
|
|
Hi,
trying to learn the GOF patterns
Good thing to learn about, I finally bought the book a few months ago.
trying to serialize my tree , filled with nodes
I had a look into serializing a tree and I got as far as serializing the objects contained within the nodes and leaves but not the actual 'tree' information such as child/parent/leaf used to construct the tree. Which meant I could not reconstruct it. When running my (C++) program I used a Windows tree control CTreeViewCtrl to visualize the data and a third party tree container to actually hold and manipulate the data and linked the two together.
I serialized the various classes that made up the objects held in the tree container using the Boost library but was not serializing the container structure. The question then arose as to should I serialize the container - which would then make the program dependant upon that container. If I did, how?
This is where I left it a few months ago.
my leaf objects cannot have children.
Leaves cannot have children, thats correct
-xml serializer cannot recognize what kind of object a child is.
I used the Boost library which got round this by allowing simple additions to class code to allow each object, when serialized, to store what type of object it was - and what it inherited from. Reconstructing then created the correct objects.
|
|
|
|
|
I would like to get some ideas on the best way to handle dealing with data in an object oriented system. Consider:
User
=======
UserId
UserTypeId
FirstName
LastName
OrganizationId
UserType
===========
UserTypeId
Name
Organization
============
OrganizationId
Name
District
YearFounded
How would you model these database tables with your objects?
For simple lookup table data, would User have a property for just UserTypeId or would it have a property of UserType(which includes both Id and Name)?
For more complex data, would User have a property for just OrganizationId or would it have a property of Organization?
If you go the route of having only an Id as property, how do you manage the display of property data, for instance, when displaying the User in the UI, you still need to display the UserType.Name value, and not just the Id. Would you load and cache a collection of UserType objects and use this to lookup the UserType.Name value when needed?
Would it make sense to expose a readonly property User.UserTypeName for convenience that provides the name value? I say readonly since you can edit the Id value, but not the actual UserType name when saving a user.
The object graph can grow large with several interactions... what rules do you use to draw the line as to where an object instance and its related graph stop?
Thanks for any opinions. Assume the objects must be WCF friendly for use as data contracts.
|
|
|
|
|
Firstly, I see no mention in your post of considering the "responsibility" of an object as part of the design process. This indicates your view of Object Oriented Design is far different than mine.
If you are asking how to mimic database table structure in your coded structures then that is an entirely different question. The most common method of doing that today is to use one of the many Object Relational Mapping tools to generate the code for you. Of course there are almost always problems associated with them but hey, if all you had to do was click a button then any monkey could do it and we would all be out of work.
Many people here on CP seem quite fond of using the new LINQ features in the .NET platform. Don't know if you can use that but if so I recommend looking into it.
|
|
|
|
|
Yeah, I guess my question is targeting the classes that might normally be created by an ORM. In our case, they are WCF data contracts, and have no behaviour.
The system also has other classes with behaviour, such as a UserBusinessManager class, that exposes methods for working with a User object, to perform actions like Load, Update, Insert, etc.
|
|
|
|
|
Hi,
the situation is as follows:
There are 2 classes - C1 and C2 - both inherited from an abstract class A. The reason is that instances of C1 and C2 are to be stored in an inhomogeneous collection, and a common base class (A) is used to access their functionality (textbook polymorphism).
The abstract class A defines an abstract method M. This is meaningfully overriden in C1, but has no meaningful override in C2.
Common sense would suggest to remove it from the abstract class if either of its derived classes are unable to override it meaningfully.
However, the logic of the situation requires M to be defined in the abstract class A.
My questions are these:
1. Is it a sign of good or bad design to write empty abstract method overrides?
2. Is it a sign of good or bad design to write abstract method overrides that only throw an exception informing the user of an incorrect usage?
3. How common are the empty abstract method overrides in real-world programming practice?
Your answers are greatly appreciated!
Lukas
|
|
|
|
|
Hi,
my 2 eurocents:
0. there is not only good or bad design, there is a continuum from very good to very bad
1. IMO overriding a method by an empty one because the functionality does not make sense is wrong.
2. throwing an exception in an override is OK
3. empty abstract overrides are only correct if that particular class needs a no-operation there; however I have never seen one.
4. FWIW, I would try and remove from the base class all functionality that is not meaningful for some of its decendents. If cats and dogs are mammals that eat and walk, and cats purr but dogs don't, then purr would not be a mammals method.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
It seems like you have a list of things, and you want to go through the list and perform an action which is only relevant to some things in it. In this case you could consider exposing an interface, and then when you iterate thru the list you can use if(item is INeedToBeNotifiedAboutEclipses) ((INeed..)item).YoItsALittleDarkOutHere();
|
|
|
|
|
Mark Churchill wrote: INeedToBeNotifiedAboutEclipses
No problem.[^]
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
|
We started getting requests to provide estimates for our development tasks, and I'm just wondering if there is a distinct breakdown into the technical design, implementation, and testing stages (from a developer's perspective) at other people's shops. If there is, I'd be curious to know what the ratios are (e.g. how much of the total development effort is spent on the technical design part, assuming you already have the preliminary specs?).
|
|
|
|
|
Of course, you should divide your development task into several stages: preliminary/concept design (~15%), detailed design (~15%), implementation (55%) and unit test (~15%).
|
|
|
|
|