I'm writing up a sample program to teach someone the basics of
database application design. I'm using the 2.0 framework and
Microsofts default "pubs" database.
What I'd like to do is create a simple app that connects to the
database and allows browsing, editing, creation and deletion of books
and authors. I'd like to show a good application architecture, with
clear seperation of data access, business logic (simple as it is), and
presentation. The student has basically been hacking his way around
application development for a while now, but has no real idea of
design.
My class design is basically as follows, but I have a few questions.
Book - Contains only book information, knows nothing about the
database. Relates 1 to 1 with the "titles" table
Author - Basically same as Book, 1 to 1 with the "author" table
Book_Record - Inherits from Book, but adds logic needed to locate,
load, and save itself to the database given a database interface
Author_Record - Basically same as Book_Record, but for authors
Books_Interface - This class has a bunch of static methods for saving,
locating, and retreiving Books from the database. It's initialized
with database interface information during the startup of the
application and passes this information to the Book_Records to allow
them to load and save themselves.
Authors_Interfa ce - Basically same as Books_Interface , but for authors
GUI Stuff - The GUI basically calls the *_Interfaces to retreive the
objects (Books and Authors) for display and editing and passes them
back to the *_Interfaces for saving.
Now, here's the problems and questions:
All Books have Authors, and all Authors have Books, but where should
the linking be done? It would make sense fot the Books class to have
a getAuthors() methods (or Authors property), but that seems like it
would start to clutter things up (as well as start pulling alot of
things into memory). Books themselves have no knowledge of the
database, or even the Books_Interface or Authors_Interfa ce. To me,
that seems like it's outside of their scope. How then, do we link the
two? I'd thought of adding methods to the Books_Interface such as
getBooks_For_Au thor(string author_id), addBook_To_Auth or(string
author_id, string book_id), etc. as well as similar methods to the
Authors_Interfa ce (getAuthors_For _Book(...)...)
Anyone have any suggestions on a clean object model? 4 1236 http://sholliday.spaces.live.com/blog/
6/5/2006
Custom Objects and Tiered Development II // 2.0
will get you started.
"---" <id**********@g mail.comwrote in message
news:11******** **************@ k78g2000cwa.goo glegroups.com.. .
I'm writing up a sample program to teach someone the basics of
database application design. I'm using the 2.0 framework and
Microsofts default "pubs" database.
What I'd like to do is create a simple app that connects to the
database and allows browsing, editing, creation and deletion of books
and authors. I'd like to show a good application architecture, with
clear seperation of data access, business logic (simple as it is), and
presentation. The student has basically been hacking his way around
application development for a while now, but has no real idea of
design.
My class design is basically as follows, but I have a few questions.
Book - Contains only book information, knows nothing about the
database. Relates 1 to 1 with the "titles" table
Author - Basically same as Book, 1 to 1 with the "author" table
Book_Record - Inherits from Book, but adds logic needed to locate,
load, and save itself to the database given a database interface
Author_Record - Basically same as Book_Record, but for authors
Books_Interface - This class has a bunch of static methods for saving,
locating, and retreiving Books from the database. It's initialized
with database interface information during the startup of the
application and passes this information to the Book_Records to allow
them to load and save themselves.
Authors_Interfa ce - Basically same as Books_Interface , but for authors
GUI Stuff - The GUI basically calls the *_Interfaces to retreive the
objects (Books and Authors) for display and editing and passes them
back to the *_Interfaces for saving.
Now, here's the problems and questions:
All Books have Authors, and all Authors have Books, but where should
the linking be done? It would make sense fot the Books class to have
a getAuthors() methods (or Authors property), but that seems like it
would start to clutter things up (as well as start pulling alot of
things into memory). Books themselves have no knowledge of the
database, or even the Books_Interface or Authors_Interfa ce. To me,
that seems like it's outside of their scope. How then, do we link the
two? I'd thought of adding methods to the Books_Interface such as
getBooks_For_Au thor(string author_id), addBook_To_Auth or(string
author_id, string book_id), etc. as well as similar methods to the
Authors_Interfa ce (getAuthors_For _Book(...)...)
Anyone have any suggestions on a clean object model?
That example is nice, but it doesn't fully apply. In the Custom
Objects and Tier Development example, there is only 1 "top level" type
object, the Customer. It appears this is the only object I can search
for and load There doesn't appear to be a way to pull up an Order
without first having the Customer. Orders appear to be loaded fully
when the Customer is loaded, which I consider to be bad for
performance ( If I just wanted a list of customer's names, I don't
want to pull all their orders into memory ).
Any possibility of extending the example to promote Orders up to top
level objects which I can load and search for and decoupling the
Customer and Order classes?
The code is to get you started.
You can just create your down OrderDeserializ er ... same principals.
And you can populate them as you need to, using an alternate stored
procedure or sql query from the datalayer (aka, getting a different
IDataReader based on a different query).
"---" <id**********@g mail.comwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.com.. .
That example is nice, but it doesn't fully apply. In the Custom
Objects and Tier Development example, there is only 1 "top level" type
object, the Customer. It appears this is the only object I can search
for and load There doesn't appear to be a way to pull up an Order
without first having the Customer. Orders appear to be loaded fully
when the Customer is loaded, which I consider to be bad for
performance ( If I just wanted a list of customer's names, I don't
want to pull all their orders into memory ).
Any possibility of extending the example to promote Orders up to top
level objects which I can load and search for and decoupling the
Customer and Order classes?
On 27 Feb 2007 12:17:58 -0800, "---" <id**********@g mail.comwrote:
>Now, here's the problems and questions: All Books have Authors, and all Authors have Books, but where should the linking be done? It would make sense fot the Books class to have a getAuthors() methods (or Authors property), but that seems like it would start to clutter things up (as well as start pulling alot of things into memory). Books themselves have no knowledge of the database, or even the Books_Interface or Authors_Interfa ce. To me, that seems like it's outside of their scope. How then, do we link the two? I'd thought of adding methods to the Books_Interface such as getBooks_For_A uthor(string author_id), addBook_To_Auth or(string author_id, string book_id), etc. as well as similar methods to the Authors_Interf ace (getAuthors_For _Book(...)...)
Anyone have any suggestions on a clean object model?
You might consider the scope provided by a real world model. A library
is a wrapper for books and has a librarian to manage details such as
the relationships between books and authors. The extra indirection
provides places for encapsulating some ugly implementation, likely
your clutter. You'll still have to figure out those relationships and
code the types accordingly.
regards
A.G. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lester |
last post by:
a pre-beginner's question:
what is the pros and cons of .net, compared to ++
I am wondering what can I get if I continue to learn C# after I have learned
C --> C++ --> C# ??
I think there must be many know the answer here.
thanks
|
by: Christian Soltenborn |
last post by:
Hi folks,
I'm from the Java world, and I want to play a little bit with VB .NET. I
have a simple question: In Java it is kind of common to have a static
main method which does nothing else then creating an object of the class
it belongs to and then to fall asleep. All real work will be done in the
object. If the program quits, it does this with System.exit(int).
How do I do something like this in VB .NET? I have source like this:
|
by: Joshua Rulz |
last post by:
Hi, i want to learn to program im quite skilled with computers and want
to learn c++. is there anyone who can teach me or tell me a good
website to learn it?
all replies will be appreciated.
|
by: Paul |
last post by:
Hi,
I'm curious how others would deal with something I'm building.
The app itself is a form of diary; it allows the organisation of diary
entries and a number of other data types.
Each diary entry is listed under its title, and double clicking brings
up the full entry and options for editing.
Each entry and associated option is stored in a diary object instance.
I'm wondering how best to store the persistent data. One option is
to a...
|
by: Jacky Luk |
last post by:
import java.awt.Graphics;
public class printtest extends java.applet.Applet
{
public void init()
{
}
public void paint (Graphics g)
{
| |
by: Johs |
last post by:
I am looking for a good C++ book for beginners. I have some experience
with C and a lot of experience with Java. I am currently reading Bjarne
Stroustrups C++ Programming Language but it starts off rather complex
without examples of compiling modules or making and using classes.
Is there some C++ books that takes you through the whole process of
making modules, compiling them and using classes?
|
by: macca |
last post by:
Hi, I'm looking for a good book on PHP design patterns for a OOP
beginner - Reccommendations please?
Thanks
Paul
|
by: Solo.Wolve |
last post by:
I've just finished the K&R c, And begin to study c++ myself,so can
anyone give me some advice?such as some books to read,and something to
notice?
Thank you very much.
|
by: ddg_linux |
last post by:
I have been reading about and doing a lot of php code examples from
books but now I find myself wanting to do something practical with
some of the skills that I have learned.
I am a beginner php programmer and looking for a starting point in
regards to practical projects to work on.
What are some projects that beginner programmers usually start with?
Please list a few that would be good for a beginner PHP programmer to
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |