-
May 4th, 2004, 12:08 AM
#1
Software architecture
To all of you who interested on designing the application model, i want to discuss what i have done in my last project, and if you don't mind please share your opinion and your design technique so i can learn from all of you.
This is the design :
I divided my application into 4 major category.
1. entity part
- this part consist of classes and will be compiled into activex dll.
- all classes are representing the database entity. as example, if i have a table named employee
the class will be CEmployee with properties represent the table entity. in this class i also implement the variable filtering (length of the string variable for example)
- all classes in this part will be used during data process.
2. database part
- this part consist of classes and will be compiled into activex dll.
- all classes are representing the database process. one process (sql statement) one method.
- the function will only return recordset for sql select.
- direct reference on entity part.
3. controller part
- this part consist of classes and will be compiled into activex dll.
- all classes are representing the programming logic. no sql statement on this part. database operation will refer to functions on database part.
- direct reference on database and entity part.
4. interface part
- this part is standard application EXE with form.
- all the programming logic will reside on controller part.
- direct reference to controller and entity part.
This architecture makes a clear separation between interface, logic, database operation and entity.
and i found this is quiet clear. but since the application is consist of many dll, i still have problem with
compatibility and packaging (dll-hel*). if you guys have any comment, suggestion, or you want to share your design technique, or anything, it would be great.
Thanks in advace, Happy coding.
-
May 4th, 2004, 04:22 AM
#2
At first glance...
Seems fine, but the second part seems a bit too much...
database part
- this part consist of classes and will be compiled into activex dll.
- all classes are representing the database process. one process (sql statement) one method .
- the function will only return recordset for sql select.
- direct reference on entity part.
It could be better to have one class with methods for:
-insert
-update
-delete
on Db
and -if needed - a class with methods like
-create
-drop
-modify
-grant priviledge
-revoke priviledge
for tables or view or stored Proc
Of course, you only can judge: your kind of design may require a
lot of methods, but is really linear (=clear). The suggested one
may have more general (and thus less) methods, but will add a
bit of complexity to the logic part of your software or it may
require other components to know how to call the db one (ie:
passing name of table - view -stored proc as parameter...)
Last edited by Cimperiali; May 4th, 2004 at 04:25 AM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
May 4th, 2004, 10:17 PM
#3
yes, there are many methods just for common function like insert, update and delete. i don't know how to create a single insert, update, delete method for all table. they can have parameters such table name, stored procedure name, etc. what about the values ? for example...if we want to call insert method, what parameters i have to pass ? table name, entities, values...doesn't it gonna make a complicated string parameter ? if you have any technique to handle this, please kindly share with me
all this time, i wonder how those great programmer design their great software. it must be good to know many design technique so we can improve our ability to create a good design.
I would appreciate it if you want to share your opinion.
Happy coding and Thanks
-
May 5th, 2004, 01:01 AM
#4
You could pass the column names and field values through as a two dimensional array. Something like:
Code:
Function dbInsert(byRef sColumns(), byval tblName)
dim nMax as integer
dim i as integer
dim sSql as string
sSql = "INSERT INTO " & tblName & "("
For i = 0 to max
If i = max then
sSql = sSql & sColumns(i,0) & ") VALUES ("
For j = 0 to max
If j = Max then
sSql = sSql & sColumns(i,1) & ") "
Else
sSql = sSql & sColumns(i,1) & ", "
End If
Next j
Else
sSql = sSql & sColumns(i,0) & ", "
End If
Next i
End Function
Of course, you can also put extra logic in there to detect what sort of variable you are sending through, so you can put quotes around the strings etc etc
Be nice to Harley riders...
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
|