Apr 20, 2016 01:16 AM
(This post was last modified: Apr 20, 2016 01:16 AM by Support™.)
Hey guys! There is a part of my assignment that I need to implement a design pattern in the project I am working on. It is a simple data management software which has only one class(Employee class) and a form for performing Create, Read, Update and Delete(CRUD) operations.
Here is my Employee class:
Then in the form operations, I use this method to create employee records:
What design pattern does this fall under?
I'm suspecting that it is either Builder pattern or Singleton pattern.
If not, can you enlighten me about what has to be changed in the above class and method to make it one of these two patterns (or) which is the easiest design pattern to follow if I have rebuild this class from ground up? It is not a complex assignment, it ends right here.
Here is my Employee class:
Code
using namespace System;
using namespace System::IO;
ref class Employee
{
private:
String^ employeeID;
String^ employeeFirstName;
String^ employeeLastName;
String^ employeeEmailAddress;
public:
Employee(String^ employeeID){
this->employeeID = employeeID;
}
public:
Employee();
String^ get_employeeFirstName(){
return employeeFirstName;
}
String^ get_employeeLastName(){
return employeeLastName;
}
String^ get_employeeEmailAddress(){
return employeeEmailAddress;
}
void set_employeeFirstName(String^ employeeFirstName){
this->employeeFirstName = employeeFirstName;
}
void set_employeeLastName(String^ employeeLastName){
this->employeeLastName = employeeLastName;
}
void set_employeeEmailAddress(String^ employeeEmailAddress){
this->employeeEmailAddress = employeeEmailAddress;
}
public:
void createEmployeeRecord(String^ employeePath){
//Writes to a file
//IO::File::WriteAllText(employeePath, employeeData);
}
public:
void getEmployeeData(String^ employeeDataPath){
//String^ employeeData = IO::File::ReadAllText(employeeDataPath);
//Reads from a file
}
};Then in the form operations, I use this method to create employee records:
Code
public: System::Void createEmployee( String^ employeeID, String^ firstName, String^ lastName, String^ emailAddress){
Employee^ employee = gcnew Employee(employeeID);
employee->set_employeeFirstName(firstName);
employee->set_employeeLastName(lastName);
employee->set_employeeEmailAddress(emailAddress);
employee->createEmployeeRecord(employeePath);
}What design pattern does this fall under?
I'm suspecting that it is either Builder pattern or Singleton pattern.
If not, can you enlighten me about what has to be changed in the above class and method to make it one of these two patterns (or) which is the easiest design pattern to follow if I have rebuild this class from ground up? It is not a complex assignment, it ends right here.

