5
голосов
12ответов
6094 просмотров

C# Class function members declaration & implementation

Is there a concept in C# of class definition and implementation similar to what you find in C++? I prefer to keep my class definitions simple by removing most, if no every, implementations details (it depends on several factors as you may know, but generally I move towards leaving most member im...

0
голосов
3ответов
204 просмотров

How to design my class

I have a class, which returns three properties. First property is dependent on some parameter, second one is dependent on the first property and third one is dependend on the second property. What is the best way, to implement this type of class, is there a appropriate design pattern for this o...

0
голосов
4ответов
2459 просмотров

C++ reference to a shared_ptr vs reference

All, I recently posted this question on DAL design. From that it would seem that passing a reference to an object into a function, with the function then populating that object, would be a good interface for a C++ Data Access Layer, e.g. bool DAL::loadCar(int id, Car& car) {} I'm now ...

3
голосов
2ответов
158 просмотров

prevent height sizing at design time

I'm working on a custom user control. How can I prevent the HEIGHT ONLY of the control from being modified during the design-time interface.

0
голосов
2ответов
468 просмотров

Temporary Storing data entered in steps in class in asp.net

how can i store different data enetered using multiple steps? Its 4-5 step procedure, user can go through each step & at the final submission i want to store it in database. I want to create class to store this data & store the data in object of that class & use it from session. I jus...

0
голосов
2ответов
640 просмотров

C++ DAL Design - Include Foreign Key Table as Composite Object

I recently posted this C++ DAL question about how best to design a 'loadCar' method in a C++ DLL, with the consensus being that 'bool DAL::loadCar(int id, Car&) {}' would be the best signature to use. Now, it so happens that in a lot of our use cases the client code will often want to retrie...

2
голосов
4ответов
266 просмотров

What relevant differences are there between anonymous and predefined classes in Java?

I have a large tree-like data structure of objects which behave mostly identical but differ in one or two methods that calculate some keys used to navigate through the structure. The divergent behaviour depends on where the objects are in the structure. I was starting out with an abstract base c...

3
голосов
2ответов
558 просмотров

Class with just Shared functions - Why is it bad?

I have a class called MembershipHelper, which I am using in my ASP.NET project. It looks like this: Public Class MembershipHelper Public Shared Function IsMultiStoreUser() As Boolean return Roles.IsUserInRole(....) End Function Public Shared Function IsAdmin() As Boolean ...

7
голосов
4ответов
1849 просмотров

Implementing IEquatable<t> where T is an interface</t>

I have a domain model that is trivially represented by the following. IMyInterface ClassA : IMyInterface ClassB : IMyInterface What I want is to implement IEquatable in such a way that I can write code something like. if(dynamicallyCreatedInstanceOfClassA == dynamicallyCreatedinstanceOfClas...

1
голосов
3ответов
262 просмотров

How can I reuse an instance of a webservice?

I am running a service A which has a class X. I am going to deploy another service B on same machine which is using this class X. How can I make sure that the same instance of service A is reused instead of another. PS:Service written in JAVA. Adding: Both these services are Axis2 services. Ser...

11
голосов
5ответов
27007 просмотров

How can a singleton class use an interface?

I read at many places that singletons can use interfaces. Some how I am unable to comprehend this.

5
голосов
6ответов
7042 просмотров

How to make a singleton class threadsafe?

I am implementing a singleton class in Java to make sure no more than one instance of the class is created.

0
голосов
6ответов
350 просмотров

How to read data for nested classes?

I'm sorry if my question isn't clear. I have a class contain some properties and one of them is "Parent" which the same type of this class. when i read data from Database i set the suitable value for each property. But how could i put the "Parent" property when i read it from database as "Paren...

4
голосов
7ответов
288 просмотров

Constructive criticism on this class

I've just reviewed some code that looked like this before public class ProductChecker { // some std stuff public ProductChecker(int AccountNumber) { var account = new AccountPersonalDetails(AccountNumber); //Get some info from account and populate class fields ...

4
голосов
3ответов
4998 просмотров

Override member data in subclass, use in superclass implementation?

In Java, is it possible to override member data in a subclass and have that overridden version be the data used in a super class's implementation? In other words, here's what I am trying to get to happen, and it's not happening: abstract public class BasicStuff { protected String[] stuf...

1
голосов
2ответов
1118 просмотров

I'm creating a Polygon class in Objective-C, should centroid calculation be a function or a method?

I'm doing this to learn about class creation and to test geometry routines. As I build the class I will add other polygon-related functionality like getting the bounding box, determining convexity, turning the poly into triangles and the like. Is it best to put that kind of code in functions or ...

7
голосов
5ответов
4484 просмотров

Class usage in Python

I write a lot of scripts in Python to analyze and plot experimental data as well as write simple simulations to test how theories fit the data. The scripts tend to be very procedural; calculate some property, calculate some other property, plot properties, analyze plot... Rather than just writi...

2
голосов
1ответов
2425 просмотров

How to integrate the Qt libraries in SparxSystems Enterprise Architect

I like to know how one can integrate the Qt libraries into an Enterprise Architect project. I do not know if it is possible at all but I tried it with partial success: I added a new package to my project tried to import qt through Context Menu / Code Engineering / Import Source Directory and sta...

9
голосов
9ответов
990 просмотров

When would you want to nest classes in C#?

Specifically, can anyone give me concrete examples of when or when not to use nested classes? I've known about this feature since forever, but never had a reason to use it. Thanks.

4
голосов
12ответов
555 просмотров

How do you go from idea to implementation when designing classes for other developers in other locations?

I'm looking for inspiration on how to design classes from scratch in a project with multiple developers in different locations (so no whiteboard sessions.) Let's say you're tasked with implementing a rather big feature that is going to be used by the other developers later in the project. This f...

16
голосов
9ответов
7483 просмотров

How many methods can a C# class have

Is there a limitation on number of properties, methods a C# class can have? I do a quick skim at Standard ECMA-334 and did not find any information on it. Before jumping into why a class with many methods are bad design, I want to be more clear on the intention. Of course I will not be writing ...

8
голосов
7ответов
2074 просмотров

Variable-length objects: Ever a good idea?

My application uses a large amount of Panda objects. Each Panda has a list of Bamboo objects. This list does not change once the Panda is initialized (no Bamboo objects are added or removed). Currently, my class is implemented as follows: class Panda { int a; int b; int _bambooCou...

5
голосов
3ответов
509 просмотров

providing an asynchronous programming model: Should I? and if so, should it be VerbAsync() or BeginVerb()?

Providing Synchronous and Asynchronous versions of Method in c# asks how to provide an async version of a method. One of the answers suggests that class library developers should avoid providing the async method, if possible, based on the single responsibility principle. Is this true? Should...

0
голосов
4ответов
659 просмотров

Preventing class data inheritance

I have a database abstraction layer that starts with a base class like so: class DB { function DB() { $this-&gt;host = "xxx"; $this-&gt;db = "xxx"; $this-&gt;user = "xx"; $this-&gt;pass = "xx"; $this-&gt;dbh = mysql_connect($this-&gt;host, $this-&gt;user, $this-&gt;pass); ...

0
голосов
5ответов
3986 просмотров

How to design a C++ class?

I wrote a application in MFC with C++. I need to write a class which can save all the data loaded from the database, These data might contain every kind of data type, such as int, string, byte, boolean, datetime and so on. We might filter, exchange columns, or sort on these data. For example: in...

2
голосов
2ответов
613 просмотров

Access to an inner struct/class in C#

I have a class that has an inner struct/class (I have decided which yet, if it matters for this I will use that) I want the inner class to be accessed from other classes but only constructed by the outer class. Is this possible? Thanks

3
голосов
5ответов
1248 просмотров

Validate constructor data

A sample class in "C# Class Desing Handbook" (pg 137) does not call the classes validation method for a specific field from inside the classes only constructor. So basically the sample class allows you to create an object with bad data and only throws an error for that data when you call the fiel...

2
голосов
2ответов
867 просмотров

Imperative vs interrogative methods

When implementing a class, is it better practice to return a value for methods (interrogative) or to simply manipulate class attributes directly within the method (imperative). For example, I have a class which builds a string to be output to a CSV file. I might do it this way: String output = ...

1
голосов
1ответов
1879 просмотров

Order of constructors for a C# class: parameterized, default, and static?

Suppose I have a class with 3 constructors, a default (no argument) constructor, a parameterized constructor, and a static constructor. like this: public MyClass() { ... } public MyClass(string arg) : this() { ... } static MyClass() { ... } Supposing I invoke the parameterized construct...

0
голосов
2ответов
242 просмотров

Design a data model to flat file transformation... delegates or inheritance?

I have a maintenance application that has to turn enterprise data (from various databases/tables) into flat files, each in a specific format, for consumption by a legacy application. I've got data models like public class StatusCode { public String Id { get; set; } public Char Level { ge...