473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

design patterns for win payroll application (I always get stuck when classes communicate with each other)

I'm in the process of working on a Windows payroll application but I wanted
some help on what design pattern I should use. For example, if my main Form
needs all active employees in the DB, I'd call from within the form, a
method called activeEmployees from class Employees. Then I'd have another
class Connection that would do the actual connection to the DB (Oracle or
SQL Server).
I've tried this before but I get stuck when sending data from one class to
the other. For example, after activeEmployees() is called during a button
click, from where should I instantiate the Connection class and call
makeConnection(DB)? And, once Connection.makeConnection(DB) is executed and
the DB is open, how will Employees.activeEmployees() have access to that
open connection? And finally, how would I be able to send that data in
activeEmployees to the initial button click that called it?

Any help would be appreciated.

Nov 15 '05 #1
2 2070
Façade is always a good pattern.
"Angel" <an**********@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I'm in the process of working on a Windows payroll application but I wanted some help on what design pattern I should use. For example, if my main Form needs all active employees in the DB, I'd call from within the form, a
method called activeEmployees from class Employees. Then I'd have another
class Connection that would do the actual connection to the DB (Oracle or
SQL Server).
I've tried this before but I get stuck when sending data from one class to
the other. For example, after activeEmployees() is called during a button
click, from where should I instantiate the Connection class and call
makeConnection(DB)? And, once Connection.makeConnection(DB) is executed and the DB is open, how will Employees.activeEmployees() have access to that
open connection? And finally, how would I be able to send that data in
activeEmployees to the initial button click that called it?

Any help would be appreciated.

Nov 15 '05 #2
Hi Angel,

I will try to describe my current design cause I think that it can help you.

I have a class Employee this class has a static property named EmployeeList
that return a strong typed collection of Employee. The thing for do it
static is cause I can load it at the start and keep it in memory, therefore
any other call to EmployeeList does not have to go to the DB.

I used a class named DataProvider to implement the interaction with the DB
backend, this class has several methods: ExecuteNonQuery( IDbCommand ) ,
ExecuteScalar( IDBCommand) , etc
now each class like Employee implement a Save() operation, inside this
method it created a Command , and call to DataProvider.ExecuteScalar() ,
now as I' m using SQL2K I create a SqlCommand,

In this escenario a Employee instance knows how it have to save it self and
it's his responsability to build the IDBCommand instance to do so, then it
use the DataProvider class to send this command to the DB, in the same way
DataProvider knows how to interact with the DB and all it does is execute
the commands other classes send to it.
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Angel" <an**********@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I'm in the process of working on a Windows payroll application but I wanted some help on what design pattern I should use. For example, if my main Form needs all active employees in the DB, I'd call from within the form, a
method called activeEmployees from class Employees. Then I'd have another
class Connection that would do the actual connection to the DB (Oracle or
SQL Server).
I've tried this before but I get stuck when sending data from one class to
the other. For example, after activeEmployees() is called during a button
click, from where should I instantiate the Connection class and call
makeConnection(DB)? And, once Connection.makeConnection(DB) is executed and the DB is open, how will Employees.activeEmployees() have access to that
open connection? And finally, how would I be able to send that data in
activeEmployees to the initial button click that called it?

Any help would be appreciated.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: R Reyes | last post by:
Hello All, I'm always looking for ways to improve my code. Most of the time (whenever I'm working on a project) I write a bunch of functions. Then after the project is finished, I put all the...
13
by: John Salerno | last post by:
Here are a few I'm considering: Design Patterns Explained : A New Perspective on Object-Oriented Design (2nd Edition) (Software Patterns Series) by Alan Shalloway Design Patterns C# by...
7
by: Manuel Bleichner | last post by:
Hello list, I have searched for some time now, but no result... I'm having the following problem: In a module I have a huge number of classes of the form: class A(object): connected_to = ...
0
weaknessforcats
by: weaknessforcats | last post by:
Design Patterns: Visitor Introduction Polymorphism requires a class hierarchy where the interface to the hierarchy is in the base class. Virtual functions allow derived classes to override base...
2
by: Lakenarr | last post by:
Hi, I need to have two objects referencing eash other. Something like this: class Planet { private Moon m_Moon; public Moon Moon {
5
by: stefven blonqhern | last post by:
hi, i imagine we've all seen this one posted before but i can't get any solutions to work for me.. for example: i have two classes MyClass and Shape. MyClass creates Shapes (and derived classes...
10
by: vital | last post by:
Hi, I am designing the middle tier of a project. It has 6 classes and microsoft application data access block. The six classes are DBServices, Logger, ProjectServices ... etc. and all these...
1
by: puzzlecracker | last post by:
Hello Group, Say I have classes A and B and the both need to maintain a pointer/ reference to each for various reasons, say optimization. And there are other classes in the project use these...
2
by: mirketiger | last post by:
I have this code it is not important tah methods have Serbian name it;s not that that's problem :) class cosinus; class sinus : public funkcija { private: funkcija *_op;
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.