Hi,
I'm designing some new class diagrams for extending an existing office automation application. In a special case I have an option to use extra fields on Entity1 to determine something or use additional data rows in Entity2 to determine that. I believe first approach is better because it does not force us to insert initial data while...
A subclass needs to know when particular events occur withing its superclass, but there are more than one ways for the superclass to break the news. Here are 2:
dispatch an event
call an abstract method which the subclass could eventually override
I was wondering if best practices would recommend one of the approaches over the other....
I have a product class which contains 11 public fields.
ProductId
ShortTitle
LongTitle
Description
Price
Length
Width
Depth
Material
Img
Colors
Pattern
The number of fields may grow with attributes for more specific product tyes. The description may contain a large amount of data.
I want to create a slim version of this product cla...
How would you fix the following bad code that passes too many parameters around?
void helper1(int p1, int p3, int p5, int p7, int p9, int p10) {
// ...
}
void helper2(int p1, int p2, int p3, int p5, int p6, int p7, int p9, int p10) {
// ...
}
void foo(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8,
int p9...
Firstly I'll show you few classes.
class A {
public:
B * something;
void callSomething(void) {
something->call();
}
};
class B {
public:
A * activeParent;
B(A * parent) {
activeParent = parent;
}
void call(void) {
activeParent->something = new C;
}
};
class C : public B {
publ...
I have an iPhone application which has some methods to gather information from the web and which then creates an object, which holds this information as properties (lets say I'll get objects of type x). Since I might need those kind of objects from various points within the application, I put the method to create one instance of the obje...
I'm trying to create a class that contains an array. However i want to require that the items in the array are themselves of a specific class. Im told there is some sort of tag you can add to do this, but for the life of me i cannot find what it is.
What i hope for is something like:
public class myClass{
public var foo:String;
...
I am somewhat confused about a paragraph in the code complete book.
In the section "Classes to avoid" it reads:
"Avoid classes named after verbs A class that has only behavior but no data is generally not really a class. Consider turning a class like DatabaseInitialization() or StringBuilder() into a routine on some other class"
My c...
Hello,
I was wondering is constantly reusing namespace names is valid for c# conventions/best practises.
I am develop most of my programs in Java, and i would have a packet for implementations, eg:
com.ajravindiran.jolt.game.items.sql
com.ajravindiran.jolt.game.users.sql
com.ajravindiran.jolt.events.impl
com.ajravindiran.jolt.tasks.im...
I've read several other questions on this topic (here, here, and here), but have yet to see a great answer. I've developed my fair share of data access layers before and personally prefer to use instance classes instead of static classes. However, it is more of a personal preference (I like to test my business objects, and this approach ...
I have just refactored a colleague's code that, roughly, looked like this...
public class Utility
public void AddHistoryEntry(int userID, HistoryType Historytype, int companyID)
{
// Do something...
}
public void AddHistoryEntry(int userID, HistoryType historyType, int companyID, string notes)
{
// Do something...
}
...
I'm working on personal project which is basically a code editor. Imagine standard File menu with menu items New, Open, Save, Save As, Save All, Close, Close All.
I'm stuck with proper design. Currently I have:
A Document class which represents a document - code editing control, respective tab in tab bar and various properties such a...
I have a set of data transfer objects (e.g. a lot of reqest, response message classes, like MainRequest, MainResponse, ShutDownRequest, ShutDownResponse) Where new classes keep coming as the project evolves. These classes must be (de)serialized from and to various XML formats with different public XSDs. New XML formats come as the projec...
It seems to me that non-public top-level classes and static nested classes essentially perform the same tasks when creating a helper class.
A.java
public class A
{
public static main (String[] args)
{
AHelper helper = new AHelper();
}
}
class AHelper {}
A.java
public class A
{
public static main...
Hello all.
Given class A, which contains sets of raw data, and class B, which contains a re-organized version (GUI ready) of that data I would like to make the raw data in A visible in B.
Clearly the raw data in class A is contained in private members. I would like to make that data visible in B though the use of something akin to the ...
I am programming a simple role playing game (to learn and for fun) and I'm at the point where I'm trying to come up with a way for game objects to interact with each other. There are two things I am trying to avoid.
Creating a gigantic game object that can be anything and do everything
Complexity - so I am staying away from a componen...
how do people deal with extra data needed to render a list.
eg I have a IList<User> Users that is a property on my viewmodel. However for each row in the user table, extra information needs to be displayed.
should i create a display model for User with the other properties included on it?
any ideas would be greatly appreciated?
...
I'm working on a project, where I need a set of classes to be designed and used for one phase of the project.
In the subsequent phase, we will not be needing the set of classes and methods. These set of classes and methods will be used throughout the application and so if I add them as any other classes, I would need to manually remove ...
Or in more specific words, is it "ok" to not be relying on setters and getters?
I'm dealing with a class that checks the availability of rooms and sets public properties of which there are more than a dozen. Things such as:
unitNumber
roomTypes ( array )
codeCorporate
codeGroup
numberKids
numberAdults
numberRooms
currency
minRate
maxR...
I have a prototype with a Form class which auto-generates an HTML form, and now I am plugging some processing functionality into the prototype.
Should the same Form class that generates the HTML for the form also process the form? Doing so would make the class have two different, distinct...yet related purposes.
Should this be one clas...