|
Member 4047183 wrote: Can anyone let me know the best way of defining the message protocol between client - server.
Requirements
|
|
|
|
|
In the past I have used datatables as my data "entity". So if I wanted a list of rooms for a house I have a stored proc for GetRoomsForHouse(HouseID) and this would reside in the Rooms class.
Now with List<> I am moving to lists of objects as my data "entity". My current structure (LoadObject) is up the FK path ie Fitting inherits from Room from House from Street etc. So getting a fitting (stool) will get 4 records from the database to load the ingeritance tree, this is fine and works well if there you are working with 1 stool.
Now I want all the fittings in Room101, this potentially generates 4 x #n fittings calls to the database to load the List<fittings>. This is still reasonable but when I want a list of all fittings in 60 storey tower block it gets a little overwhelming.
In the past I would simply have a proc to get all fittings by a number of different criteria and use the datatable to load the display controls. So I have a number of option to follow:
1. Continue with the proc to datatable - this precludes using a List<> to populate data list controls
2. Use the LoadObject method and wear the database calls - worst case and will not be implemented
3. Use a proc to get the data IE Fittings RoomName,HouseNo,StreeName etc and create a class to service a List<fittingsforxxxx> with the results from the proc.
4. Split my design of an object to display/process where display gets only the data used to load into list controls. The process object would be a full inheritance tree of a single object (Fitting).
I want to use 3 but it means there will be a plethora of classes in the app to support display. 4 may be the better option as it standatdises on the object rather than the proc.
The amount of code is not an issue as I will use my code generator to build it all.
2nd issue
When dealing with lists of objects should the list reside in the parent or the child eg:
Room has a List<fittings> and while the select for the List is on Fittings the List is on Room - Parent has the list.
Fittings has a List<fittings> for a Room and retains the List on the Fittings object - Child has the list.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't understand your question. Is your question basically that you know how to load one object from the database but loading multiple objects seamlessly from the database (or any storage) you are having trouble with?
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
I thought I had wasted my time with this question.
No I have no problem managing the data it is the design I am tossing around. When dealing with a list of something do I create the list in the something class or in the parent class.
2 classes, Department and staff. I now want a list of staff for the department. Is the best design I am after.
Departmant
List of staff for department(this.DepatmentID)
Staff
Get for Department(DepartmentID)
Or both, hah thats probably the right way. Staff gets the list for a department because it is a list of staff and department calls the same method on staff to get the list of staff for itself.
The problem is I use stored procs ALL the time so there would be a proc out there called StaffGetForDept(@DeptID) and deciding on the owner class for the proc is sometime an issue.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't like the idea of asking the Staff object to return a list of Staff objects. A staff should have methods and properties for a Staff but not a list of Staff. I would take one of the collection classes (if using .NET or something similar if using else) and extend it like below:
public class StaffCollection : List<Staff>
{
private Department _department;
// Inject the object with the department at construction
// Now this staff collection realizes its department
public StaffCollection(Department dept)
{
this._department = dept;
}
public void Load()
{
// Load this from the database. I will create a DAL and pass a reference of this to it so it can load it for me.
}
// You can put many other methods--based on your requirements--here. For example, find all employees who earn more than 100K and it will return a bunch of employees who wear pink shirts and have spiked up hair
}
Here is the department class
public class department
{
// put everything for department here: email, name etc.
private StaffCollection _staffs;
public Department()
{
this._staff = new StaffCollection(this);
}
public void LoadStaff()
{
// You can check first if already loaded or just reload everytime
this._staff.Load();
}
}
You will still need a Staff class and might need a DepartmentCollection class.
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
CodingYoshi wrote: I would take one of the collection classes
Now that makes sense, I have no collection classes in my design, all the lists (I usually use datatables) come from the single class, this is b/c of my reliance on datatables (and recordsets of course) in the past.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I think I've got a god object antipattern problem, or not, please tell me:
I have a class Admin that contains several lists of things that might interact each other,
for example: It contains a list of Messages, Accounts, Contacts, Filters etc.
The problem is that some of them interact with each other.. for example, the AddMessage method applies all the filters in the filters list.
The Admin class is pretty big.. because it haves Adds methods, Deletes methods, ..so it has like 2*(fields that are objects or lists of objects) methods
Do i have a god class or is it well justified?
In case I do have a god class, should I split the Admin class in several Administrators? like AccountsAdmin, ContactsAdmin, FiltersAdmin, ..? or what?
Thanks
|
|
|
|
|
I would have an Admin PROJECT and a class for each of your entities (accounts, contacts etc)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You didn't get the problem.
I DO have a class Account, Message, Filter, etc.
|
|
|
|
|
Quake2Player wrote: In case I do have a god class, should I split the Admin class in several Administrators? like AccountsAdmin, ContactsAdmin, FiltersAdmin, ..? or what?
I assumed the admin for the classes is done in the one Admin class. I try to keep any lists etc in thier respective classes eg the Contacts list is always found in the Contacts class and admin uses the ContactClass.List, it never has a copy of its own list of contacts. If Filters need a contact or list of contacts it goes to the contact class, admin does the same.
The only time I vary this is if Filters needs a special list of contacts and Thingy needs a different list of contacts for some reason. Then I allow the other classes to have their own lists internally.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Quake2Player,
Read my reply to MyCroft Holmes question above and it should/might help you.
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
I'm looking at a new project where the customer wants to use RS232 serial comms to exchange information between 2 embedded systems.
(They need the new system to support legacy boxes, they can change the protocol on the old boxes but will not chnage the hardware. At the momment each box has is own way.)
I'm having trouble locating an industry standard for the protocol. I've found ISO 1745 which looks like it should do the job but its dated 1975 and that just feels wrong.
Does anyone know of a more recent industry standard that defines point to point data exchange over RS232?
Thanks
Alec
|
|
|
|
|
AlecJames wrote: Does anyone know of a more recent industry standard that defines point to point data exchange over RS232?
It seems to be discussed here[^] and there are reference links at the bottom that may link to the specs.
|
|
|
|
|
Hi,
you can use any protocol you like, or come up with your own; I often have.
It all depends on your needs (throughput, reliability, recovery, multi-drop, etc).
One not so simple example is SLIP.
If you roll your own, first decision is binary versus text (compactness versus ease of communication, getting all characters through the driver/modem/...).
Whatever you choose, make sure you know to locate the end of each message: either prefix the length, or set a unique terminator (CR and/or LF on text).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Experts , getting into the details directly , I'm doing a 3 tier application and I have some questions before I start coding.
1. we have 2 servers one for the database and the other for networking and domain control, since this is a 3 tier application I assumed I have to lay one of the layers on the DC server, BLL layer for example and I'm still confused about the DAL layer if better to locate it on the DC server or on the DB server ?
2. What about ConnectionStrings and References - VisualStudio C# 2008 - , as I'm working on my development laptop , I want to work even when I'm not at work . If I simulate the environment locally can I move it to the real world gently ? and how can I do so ?
Thanks in Advance
|
|
|
|
|
1. The tiers are a conceptual separation, not a separation over servers. May I suggest that you keep both the DAL and the BL on the DB-server? That would save you from writing (secure) communication-code between those layers.
2. Yes. By putting the connectionstring in a configuration file.
I are troll
|
|
|
|
|
I have a scenario where I have three combos. All three are populated with the same data, but use different fields from the data for their display text. The Extension, Name, and Room combos are all populated from the Extension table. If the user selects an extension, the Room and Name combo selections must update to the values for the selected extension. The same if they select a Name, then extension and room get updated.
Often, many extensions are found in one room, or under one name, etc. So now, if the user selects a 'busy' room, what I figure I'll do is filter the extension combo to only those for that room, and give a visual indication of this, maybe a visible link between the combos. If the user decides they wish to ignore the room, and search all extensions, they click a 'clear' entry in extensions, and it loads all the extensions.
Is this a feasible way of doing this? Are there any established patterns for scenarios like this?
|
|
|
|
|
We do something similar except we use check boxes to determine whether or not to link the combos. The check boxes provide the visual feedback so that the user knows whether or not they're seeing filtered data and at the same time allows them to control whether or not they want to see filtered data.
I don't know of any established patterns for this but it really doesn't take that much to implement a solution.
|
|
|
|
|
Hi,
I'm modeling a tagging system, like my own html, for an application... and this is what I have till now:
class Tag:
+Tag(string) //example new Tag("<i>...</i> ... <s>...</s>")
+string Name //for example "b" (for a tag which is used like <b>..</b>)
+string Content //example "<i>...</i> ... <s>...</s>"
+Tag[] Tags //the subtags used within the content of the tag, in the example above it would return the tags t1 and t2 (i and s)
But i need more ideas before getting into the code so I dont get a headache within the process
Thanks.
|
|
|
|
|
Also somehow I need to have a list of possible tags, for the parsing -private- method..
Maybe another class, TagAnalyzer?
|
|
|
|
|
If one or more private methods of a class need a variable to perform some operation on, should one methods pass it to the other as parameters or should we make the parameter a private member of the class so both methods can access it?
If we make it a class level variable then it will exist for the lifetime of the object. If we do not need it for the lifetime of the object, we are wasting resources.
If we do not make it a class level variable then we have to pass it around to methods which need it. I am not sure what the disadvantage is here.
If the class has 7 methods and 5 of them need the variable then we will pass it around to all these methods. If class level, then we will not need to pass it but it will exist for the lifetime of the object.
Should it depend on how many different methods need the variable or should it depend on whether we need its existence for the lifetime of the object?
What are your opinions? Any conventions?
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
Hi,
it depends on the circumstances.
If the parameters are like characteristics of the objects, then data members would be alright.
If they are small, then having storage allocated for them for the lifetime of the object probably is irrelevant.
If they more act like operational parameters, seems to me method parameters are in order; if they are many, you may want to create a separate struct or class to hold them and pass them around easily (kind of "job ticket").
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I'm lookin for a design-pattern that match what I need: I have class A which should hold a collection of class B or its inehrited classes. class B should be able to run functions and access properties on A and A should be able to run functions and access properties on B.
I've been suggested to pass reference of As properties to B opon construction, but I'm lookin for the design-pattern...
anyone know of any design-pattern similar to this?
Thanks alot
NaNg.
|
|
|
|
|
That is the pattern, pass A to B in its constructor. Or make B an inner class of A so only A can create it and without A its creation will be impossible. Here is a snippet:
A a = new A();
B b = a.CreateB();
public class A
{
...
public void CreateB()
{
A a = new A(this);
return a;
}
...
public class B // Or other access depending on your needs
{
B(A a)
{
this.a = a;
}
}
}
CodingYoshi
Visual Basic is for basic people, C# is for sharp people. Farid Tarin '07
|
|
|
|
|
the thing is - i was strongly advised not to hold the A class instance in Bs instance, someone told me it's bad design.
What do you think? is it that bad of a design, could there be better? or this is the best option there is?
|
|
|
|