A template for declaring a type of object.
-4
votes
0answers
27 views
Hooking into partial class' property change [closed]
I have an auto generated POCO class and manual extensions to it, following:
public partial class Company // Auto generated
{
public Guid Id { get; set; }
public string SiteId ...
3
votes
1answer
57 views
CharSequence to represent a named object
I always followed the opinion to not abuse interfaces in case of decomposition.
Usually I only implement them if I am absolutely sure to have a "is-a"-relation and avoid implementing them if there is ...
1
vote
1answer
67 views
Is it OK to use (WTF) forms to refer stuff from DB?
Form classes are intended (IMO) for submitted data against rules. For example: are passwords equal, is end date later than start date.
submitted data--->|Form|
Is it okay for Form classes to ...
2
votes
1answer
41 views
Should I be taking these as arguments or define them in a sub class?
So I am making a mario clone in pygame and I have a base class Character and two sub classes, Mario and Luigi. The methods that the Character class defines require a significant amount of attributes ...
1
vote
4answers
210 views
What are the differences between class variables and instance variables in Java? [closed]
I'm very new to Java and want to be difference between class variables and instance variables.
For example:
class Bicycle {
int cadence = 0;
int speed = 0;
int gear = 1;
}
How are ...
-3
votes
1answer
129 views
Good practice to hold Constants in their own file? [duplicate]
I've noticed some projects like to store constants in their own file, i.e constants used globally and in the main program loop might clutter the main file so perhaps they look to place them elsewhere ...
66
votes
13answers
6k views
Do objects in OOP have to represent an entity?
Does an object have to represent an entity?
By an entity I mean something like a Product, Motor, a ParkingLot etc, a physical, or a conceptual object, something that is well defined, with some core ...
2
votes
1answer
113 views
Python Classes and Design Questions
What is the best way to design a class to see if an update occurs on a property?
I have a whole bunch of classes, and current am going through a re-design of the python package I created. ...
0
votes
0answers
54 views
Class design for Token, TokenType and regex constants
For use in a lexer class a have a class Token which represents a token of a specific type and its value, while the types are defined by the enum TokenType in which every token holds its own regular ...
4
votes
3answers
139 views
Unit of Design Versus Unit of Re-use. What is the difference?
Contemporary object-oriented programming languages employ the class as the unit of reuse. At the same time, the class is also the unit of design. This implies that to reuse a class, the design ...
1
vote
4answers
284 views
Why I need to make method of my class private, If I need to access it throughout my application?
I am going through the beginners tutorial for C# from a website
http://www.homeandlearn.co.uk/csharp/csharp_s10p1.html
On chapter of classes, it makes the method of class private and then use ...
5
votes
1answer
157 views
Nested classes via a getter (to emulate namespacing)
So, we all know that ES6's introduced syntax is definitely sugar over what we've been doing, previously. That being said, we still don't have namespaces (which would be nice...)
The problem that I'm ...
0
votes
1answer
174 views
Setting up folders and importing modules in Python
I'm building an app to automate some processes that are annoying to do by hand (looking in a file, taking certain information out of a file, building another file with that information).
My project ...
1
vote
1answer
49 views
What's the best way to store class/type info in a plugin system in your software?
There are lots of applications like 3ds Max, Maya, etc that allows you to use plugins, where even the default nodes are created as plugins.
This is all good but if the developer changes the ...
1
vote
2answers
225 views
Are any side effects not concrete side effects?
In Chapter 23 of "Object Oriented Software Construction" (1988), Betrand Meyer makes a distinction between side effects, concrete side effects, and abstract side effects.
Meyer defines a side effect ...
0
votes
1answer
152 views
Best OOP practice for object vs dataservice [duplicate]
I am working on a new project and am curious as to how I should go about doing something properly.
Lets say I have a table called "leads" in my database. This clearly means that a single "lead" would ...
0
votes
0answers
44 views
Internal class variables convention
When I see some open source projects, specifically classes, I see that its variables starts with a 'm' minuscule. What does it mean? What means the 'm'?
2
votes
1answer
199 views
Static properties and implicit “self” property in structures and enumerations vs classes in Swift
I am currently reading the Swift language documentation and came across these sentences in the chapter about methods:
Similarly, type methods on structures and enumerations can access
static ...
1
vote
5answers
493 views
Are there too many parameters in this constructor? [duplicate]
Check this out:
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\View\DesignInterface $design,
\Magento\Framework\Registry $registry,
...
1
vote
3answers
226 views
OOP implementation doubts with databases
I was starting a project today and after designing the database structure and how the data would be stored etc, I started the implementation. I am doing this on php, but the language isn't really ...
4
votes
2answers
248 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
190 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# ...
15
votes
4answers
1k 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 ...
3
votes
1answer
124 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
60 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, ...
0
votes
1answer
105 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?
9
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
145 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
147 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
188 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
1k 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
187 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
281 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
204 views
Confusion about associations in UML class diagram
--------------------- ----------------------
| FLIGHT | | STEWARD |
--------------------- ----------------------
| Arrival time | | Steward ID |
| ...
4
votes
2answers
234 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
235 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
93 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
331 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
292 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 ...
5
votes
6answers
2k 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
295 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
44 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 ...
2
votes
1answer
169 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
100 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
2k 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
390 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
133 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):
...
5
votes
7answers
834 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
2k 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 ...