I have a class called Player in the business layer of my web application.
Player class has fields PlayerID, CategoryID and CountryID
A function in Player Class calls a function in PlayerDB Class in the Data Access Layer which in turn calls a stored proc which returns data for PlayerID, CategoryID (foreign key to Category table) and Cou...
BACKGROUND: I have a custom class written in C# (2005), with code similar to the following:
public class Savepoint
{
public int iOffset; /* Starting offset in main journal */
public u32 nOrig; /* Original number of pages in file */
public u32 iSubRec; /* Index of first record in su...
I thought to seek this answer from stackoverflow community that how to decide to go for composition or generalization when we are designing classes.
...
Hi,
Assuming you have a class Photo:
class Photo
{
public string Title {get; set;}
public string FileExtension {get; set;}
public void Save()
{
// Save to backing store here
}
}
Which would be the best place to check whether the values have been set correctly. In the propert setter or the Save method.
Edit: What if ...
I want to write some methods in a class so that other classes can call these methods using [instance methodName:Parameter].
If the class is a subclass of UIViewController, I can use initWithNibName to initialize it. But I want to write the methods in an NSObject's subclass, how can I initialize it?
...
I want to send a string from one class to the other:
1) In class1, I add a property to hold the string:
@property (nonatomic, retain) NSString *str;
2) and a method to send back a string:
-(NSString *)sendBackStr:(NSString *)strURL
{
NSString *str = [[NSString alloc] stringWithString:strURL];
return str;
}
3) In class2, I...
I write an instance method in ClassName.m:
-(void)methodName:(paraType)parameter
{...}
And call it using [self methodName:parameter]; A warning will pop up, but the code still runs successfully.
Is this because I haven't created an instance of the class? Why the method still runs normally? And what is the correct way to call self meth...
The project I'm working on has just hit 4200 lines in the main C# file, which is causing Intellisense to take a few seconds (sometimes up to 6 or so) to respond, during which Visual Studio locks up. I'm wondering how everyone else splits their files and whether there's a consensus.
I tried to look for some guides and found Google's C++...
I'm a former classic ASP programmer and sometimes PHP programmer writing my first ASP.NET application. I'm loving the much-improved ADO.NET functions, but I'm feeling the need to write a database class. Partly I want to consolidate the code that actually interacts with the database, and partly I want to reduce what feels like repetition....
i created web project, and added new class library for framework. This framework includes DAL. But added reference . And running no this give me no fail.
runnig give me error:
" A project with an Output Type of Class Library cannot be started directly
In order to debug this project, add an executable project to this solution which ref...
hello,
I wanna declare a record inside a class as follows:
class player (x, y)=
object(self)
type gun = {x:int; y:int; active:bool}
val guns = Array.create 5 {x=0; y=0; active=false}
....
but the compiler claim that this line is syntax error : type gun = {x:in ....
when declared outside the class like this
type : gun...
I want to create a class to handle all the HTTP connection work for other classes(in order to avoid writing codes repeatedly).
I call it ConnectionCenter(subclass of NSObject) and add the following codes to it:
-(void)connect:(NSString *)strURL obj:(ConnectCenter *)objConnect
{
NSURLRequest *theRequest=[NSURLRequest requestWithURL:...
I am still trying to workout separation of function and how it applies to class creation and namespace inclusion. I have a custom class SoftwareComponent which when presented to the user will most often appear as a ListItem. Is creating a ToListItem method a good idea? I worry because I have now placed a dependency in the class which wil...
I am designing a class...
there are crucial methods that need an object passed to them or they need to be able to "get" an object.
So the question is, should you use getter/setters OR directly send the object as an argument to the method - in order for the method to work properly. Or should you set objects via the constructor if they ...
I want to create a special class for holding a lot of values like strName, strNo, intPassword...So that several other classes can modify the same value in this class.
I want to use the dot syntax to call its properties like Values.strName = ...;
I don't want to initialize the class everytime before I read/write its values because some o...
currently i am discussing if placing entity at the end of each entity is a good practice for example
public class CustomerEntity:BaseEntity{}
instead of
public class Customer:BaseEntity{}
in my career i had seen both, but how do you do it nowadays?
...
I'm extending (not sure if it's the right word here) a partial Cart class that got generated in Linq to SQL database model.
The business logic is that there can be only one Cart per customer. If a customer doesn't have a cart, it should be created; if a customer has a cart, it should be returned.
Here's what I'm doing:
public partial...
I created an indenpendent class for HTTP connection. All the connection works fine. The problem is that I find method 'didReceiveData' will be called AFTER the method who call the connection. (method 'didReceiveData' will be called after IBAction 'accept')
- (IBAction)accept:(id)sender {
[self connect:url];
//labelStr = ReturnS...
While filling in The Object Oriented Concepts Survey (To provide some academic researchers with real-life data on software design), I came upon this question:
What is the limit N of maximum methods you allow in your classes?
The survey then goes on asking if you refactor your classes once you reach this limit N.
I've honestly never th...
There is a Checkstyle rule DesignForExtension. It says: if you have a public/protected method which is not abstract nor final nor empty it is not "designed for extension". Read the description for this rule on the Checkstyle page for the rationale.
Imagine this case. I have an abstract class which defines some fields and a validate meth...