The tag has no wiki summary.

learn more… | top users | synonyms (1)

4
votes
2answers
225 views

Should I use properties for the properties of properties?

Sometimes I use some indirect properties to set or get some other sub-properties, I give an example class Page { public string MainText { set { MainParagraph.Text = value; } get { return ...
0
votes
1answer
69 views

Should I prefer classes or singletons in JavaScript/Node?

This question applies especially to Node.js, but also to JavaScript in general. I started working on a simple web app in Node.js. I'm relatively new to Node and JavaScript, and come mainly from C# ...
12
votes
4answers
763 views

“Use map instead of class to represent data” -Rich Hickey

In this video by Rich Hickey, the Clojure creator, he advises to use map to represent data instead of using a class to represent it, as done in Java. I don't understand how it can be better, since how ...
2
votes
1answer
79 views

When to use nested classes and when to use namespaces?

I have really never made use of namespaces, and am considering them at the moment. My situation. I have a class Reverb. It contains as members instances of other classes, declared in the same header ...
0
votes
1answer
51 views

Comments for a class that isn't an entity

According to Java's commenting conventions, classes comments should describe a "thing", rather than "actions". It is easy when the class IS a thing (ex. a Clown), but what if it isn't? In this case, ...
-1
votes
1answer
99 views

Why is it said that a class represents an abstraction? [closed]

I think that abstraction represents only the essential things needed for the purpose as there are so many unnecessary properties. So why is it said that a class represents an abstraction?
8
votes
5answers
2k views

class in OOP language and type

In programming language theory, a type is a set of values. E.g. the type "int" is the set of all integer values. In OOP languages, a class is a type, is it? When a class is defined with more than ...
1
vote
2answers
88 views

Class as resource handle & Bad Copy

I am reading Bjarne Stroustrup's book titled "A tour of C++". The following section is confusing to me: When a class is a resource handle – that is, when the class is responsible for an object ...
1
vote
1answer
53 views

Splitting single Class into multiple Classes

I am writing automated test scripts with Selenium Webdriver (Python) and I try to follow the correct programming practices, specifically the Object Oriented methodologies, where possible. At the ...
1
vote
1answer
139 views

How to represent “class” data type in C or any low level language? [closed]

I'm writing a simple language compiler,currently it's support functional programming only. I want to support OOP concept, but I don't know how exactly I can represent an object ? just where to start ...
4
votes
4answers
978 views

Refactoring: When to add a new class in the project?

When do you feel that you need a new class (maybe when you are developing or after development for refactoring purpose)? Maybe I can start from my existing variables and think how I can reorganize ...
1
vote
1answer
94 views

How to store/deal with data available to other classes

I'm writing a CAD program. Let's say I have in input class, this class reads various data from a text file and creates lots of lists/dictionaries and .... These data need to be accessed by other ...
1
vote
2answers
233 views

Is using multiple static classes with maximum one public method is a good idea

I'm writing a structural detailing (CAD) software for concrete buildings in C#. I have defined like hundreds of static classes each with one public method and if needed some private methods. Each one ...
1
vote
2answers
91 views

Confusion about associations in UML class diagram

--------------------- ---------------------- | FLIGHT | | STEWARD | --------------------- ---------------------- | Arrival time | | Steward ID | | ...
4
votes
2answers
162 views

In Python, is there any difference (apart from a few listed exceptions) between classes and dictionaries?

My logic goes like this: def A(val): return {'a':val} print(A(7)['a']) is the same as class A: def __init__(self, val): self.a = val print(A(7).a) Obviously, there are problems ...
1
vote
2answers
170 views

Will there be a memory or processing time difference between a class member function and a global function

I'm writing a neuron network simulation program and every operation or additional byte per neuron scales insanely. I prefer C++ as a language over the others, but now I'm wondering if the class ...
0
votes
1answer
65 views

Storing Form Data in a class

I have a form that writes to a database. Other than creating a class handle an external API, this project is done. However, the processing script is your standard procedural calling of queries using ...
1
vote
2answers
295 views

What is the purpose of creating a member function with the same type as its class?

I'm sure I'll botch some of the specific terminology, but what is the difference between object and object2 in this implementation? Is the only purpose of the first method (prototyping the class's ...
1
vote
2answers
237 views

Decide the type of an object during runtime

I try to implement a PriorityQueue with C#: public class PriorityQueue<T> : Heap<T> where T : IComparable<T> { ... } The Heap is abstract. I have MinHeap and MaxHeap that are ...
3
votes
6answers
944 views

Unit test private method in c++ using a friend class

I know that this is a debated practice, but let's suppose that this is the best option for me. I am wondering about what is the actual technique to do this. The approach that I see is this: 1) Make a ...
1
vote
2answers
259 views

When should I refactor a private class into a package-private class?

When I began implementing a class in my system (let's call it A), I realized I needed some kind of object that does something. So I needed a new class (let's call it B), but I made it a private static ...
0
votes
0answers
56 views

Is it good to make singleton Log classes for Entity classes [duplicate]

I am little confused about the technique i use in almost all applications i wrote ,i think i am going wrong I make Entity class Forexample Person, Adress ,Class and then to save it i make AdressLog ...
0
votes
0answers
43 views

c++ coding practice class vs. “free” functions [duplicate]

I am currently writing my first bigger project in c++. Its basic linear algebra. I am aware that boost libraries and others exist, but for various reasons I need to write my own. Purpose of the ...
-3
votes
2answers
188 views

Why friend in C++ should be in the header file? [closed]

Friend function/class, FriendOfX for some arbitrary class X is an implementation detail of class X. Why in C++ we have to declare them in the header file? Are there any compelling reasons to make this ...
2
votes
1answer
99 views

class hierarchy with structurally different subclasses

I want to implement a protocol layer which sits on top of the TCP/IP stack. There is a limited set of PDUs that can be sent and for each PDU there is a class which represents it in a structured form. ...
1
vote
2answers
92 views

How specific should be an interface about its implementation details?

Perhaps I should have picked a better title, but anyway... Basically what to do with two or more implementations that have the same public interface, but they are meant for slightly different ...
1
vote
2answers
874 views

A vector of pointers to different derived classes of the same base class

I am writing a game in C++ which has different enemy types. I have defined a base Enemy class and I also have derived classes enemy1, enemy2 etc. Now for updating these enemies in each iteration of ...
0
votes
2answers
285 views

Working with Javascript classes the right way

Comparable questions have surely been asked before but I'd like to hear some words about my specific way of implementing Javascript classes. Let me first start with a Javascript example taken from a ...
1
vote
1answer
99 views

Using class like an object in Python

I am learning from Learn Python the hard way where I have come across a study drill where they want to know that whether a class can be used like an object. As I have experimented: class A(object): ...
3
votes
7answers
728 views

Significant amount of the time, I can't think of a reason to have an object instead of a static class. Do objects have more benefits than I think? [closed]

I understand the concept of an object, and as a Java programmer I feel the OO paradigm comes rather naturally to me in practice. However recently I found myself thinking: Wait a second, what are ...
0
votes
2answers
914 views

Question about casting a class in Java with generics

In Java 6 Class<? extends ArrayList<?>> a = ArrayList.class; gives and error, but Class<? extends ArrayList<?>> b = (Class<? extends ...
2
votes
0answers
108 views

How to build child classes as parent configuration?

I'm using Codeigniter PHP Framework for developing a web application, and when developing an admin zone, I've ended building a generic parent class called AdminController which is extended by the ...
2
votes
2answers
308 views

MVC: “User” model gets big and crowded. Should methods that do CRUD operations on one-to-many relationship data be in different models?

In most MVC web projects there is a User class. Many times a user has something else in a one-to-many relationship, i.e. orders. If we have a user class that has many orders, should methods that add, ...
2
votes
1answer
224 views

UML class diagrams: How to show dependency

Please consider a program with four classes: Class A, B, C and D. Classes A and B are subclasses of abstract super-class C. Class D is dependent on C. Meaning: It holds a C objectOfTypeC field. As ...
26
votes
8answers
6k views

Why have private static methods?

I just wanted to clear up a question I have. What is the point of having a private static method as opposed to a normal method with private visibility? I would have thought an advantage to having a ...
2
votes
2answers
100 views

How to invoke a method in a class always when the class is accessed - like a reaction? [duplicate]

I am working on a C# net micro framework project, in particular an I2C bus class. I have several different I2C devices each defined in separate classes which contain all of the devices' unique ...
1
vote
2answers
6k views

Suggest a best practice to create Constants class

There is a debate in between my team members about declaration of Constants class. We are moving the constant variables into separate class as like below public class Contants { public const ...
2
votes
2answers
260 views

Should I always start with UML as a good practice when designing classes?

I am in the middle of creating a Bundle for PHP application based on Symfony 2. I want the bundle to be clear and good designed, so I constantly move and refactor code, rename methods, reorder ...
1
vote
5answers
196 views

Clarification about Polymorphism / Inheritance

I am trying to better my understanding of polymorphism. Say I have a base class called baseClass with one method called foo() and I have three derived classes called derived1 , derived2 and derived3 ...
1
vote
1answer
161 views

Dynamic method creation in python

I have a class that will have a number of external methods that will all call the same smaller set of internal methods. So something like: obj.method_one(a, c) and obj.method_two(a, c) where ...
1
vote
1answer
416 views

Changing method signature for implementing classes in PHP

Is there any decent work around to PHP's lack of Generics that allow static code inspection to detect type consistency? I have an abstract class, that I want to sub-class and also enforce that one of ...
0
votes
1answer
220 views

In objective C, where does the inheritance chain end? [closed]

In objective C, classes are objects, but what object owns the class objects? I am trying to get as detailed an understanding of iOS programming as I can, and this question popped into my head, so I ...
1
vote
2answers
273 views

Preventing some downsides of a static class

Here is my situation. I have implemented the accepted .NET 4.0 answer in this question, which is working. However, my codebase is quite large and as responsible for this code I've started getting ...
1
vote
1answer
549 views

Is it good or bad practice to provide separate classes for an object: one to build it, and one to use it?

Suppose I'm writing some C++ code to visualize "Foo" objects. I have two ways of getting a "Foo": computing it from data, or from taking the pieces of a precomputed "Foo" and building a new "Foo". ...
0
votes
2answers
565 views

In PHP, should I delete objects immediately after use?

I've read in PHP Advanced and Object Oriented Programming by Larry Ullman that it is good programming practice to delete object immediately after use but reason is given nowhere. I am a student web ...
2
votes
2answers
1k views

Concrete types - as described by Stroustrup - C++ Programming Language 4th ed

I'm having a hard time with this concept. What is Stroustrup getting at here? What is special about a class whose "representation is part of its definition"? What does a "concrete type" contrast ...
1
vote
3answers
280 views

Better style for member variables?

class awesomeClass { std::list<A> myList; //... void fillList(); }; awesomeClass::awesomeClass() { fillList(); } void awesomeClass::fillList(){ //... foreach(A a, ...
13
votes
6answers
2k views

Should a class know about its subclasses?

Should a class know about its subclasses? Should a class do something that is specific for a given subclass for instance? My instincts tells me that is a bad design, it seems like an anti-pattern of ...
0
votes
1answer
357 views

Basic OOP theory: misunderstanding surrounding database and user classes

New to OOP and trying to understand some basic fundamentals. Currently using PHP5 to build a basic web app. In using PHP's built in PDO as my database class and a separately created user class that ...
1
vote
1answer
338 views

UML class diagram - can aggregated object be part of two aggregated classes?

Some sources say that aggregation means that the class owns the object and shares reference. Lets assume an example where a company class holds a list of cars but departments of that company has list ...