Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [object-oriented]

A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner

0
votes
1answer
103 views

Why isn't there a static initializer in Python?

The equivalent of static { // Code here } does not exist in Python by default. The closest thing, while being "Pythonic", seems to be to create a decorator and do the initialization there such ...
0
votes
1answer
46 views

freeRTOS C++11 queue with pointers inside, object-oriented

I thought about this problem I was having. I have producer-consumer type of design with two user-created-tasks sender, and reader. Queue is used to communicate between reader-sender. Currently the ...
-1
votes
1answer
51 views

How do you call a class that is inheriting another class?

If class is declared like this class Foo : IFoo From IFoo point of view, Foo is called implementation. If class is declared like this class Foo : Bar Then Foo derives from Bar. How do you call a ...
0
votes
1answer
86 views

Can a class factory also save the object to a database?

How can a factory also save the object in the database? I want to create an object that consists of other objects. Pseudocode: firstObject = db.get....; secondObject = db.get....; expectedObject = ...
0
votes
0answers
59 views

What's the benefit of separating specialised data from behaviour in an algorithm?

Functional programming strongly suggests to separate data from behaviours (functions). However, I can't see the benefit of this for an algorithm's implementation intrinsically tied with particular ...
0
votes
3answers
121 views

Calculating the total price of items in a shopping cart

I am making a shopping cart. A shopping cart will have a total amount of money you've got to pay for the products you've selected. I'd like to approach the problem using both OOP (encapsulating it) ...
2
votes
3answers
264 views

Is it safe to put SQL statements in my C# application?

I'm making a medium sized application to be distributed privately to several Churches. It connects to an Azure database but it does not have any server managing the information (apart from the SQL ...
1
vote
1answer
61 views

The main reason for using the command design pattern for game AI

I've been going through all the design patterns in context of game programming form this book, before starting my next big project. Apart from that I've been reading about them in more general context....
0
votes
1answer
58 views

C++11 freeRTOS questions about queue usage and object design

Background I'm writing C++ firmware with freertos to penplottingrobot. It's a makeblock XYplotter and the firmware is connecting to mDraw software for command instructions thru USB drivers. MDraw ...
2
votes
2answers
359 views

Is it bad practice when an Object has to be aware of another Object

I was reading this page and came across this sentence in the accepted answer: I don't like A directly knowing about B. But that's a DIP thing not a POJO thing. What if you can't abstract out B ...
19
votes
5answers
1k views

continuous integration for scientific software

I'm no software engineer. I'm a phd student in the field of geoscience. Almost two years ago I started programming a scientific software. I never used continuous integration (CI), mainly because at ...
-2
votes
0answers
76 views

Are large object graphs used much anymore? [closed]

Are the days of large object graphs done? When I first learned to program, there was not a whole lot of discussion of architecture and design. Algorithms and data structures were the core (as it ...
-3
votes
1answer
56 views

Object Property in object-oriented paradigm [closed]

Within object oriented paradigm, can object property become a new object ? For example, the sun (the star) has the properties name, temperature, mass, diameter, etc. And one can create methods to do ...
-3
votes
3answers
119 views

OOP and class that inherit from many classes

In OOP, is it possible to have a class that inherits from multiple other classes? And if yes, how is this situation called? For example, suppose I have the following classes: Eye Nose Mouth Eyebrow ...
0
votes
1answer
33 views

Should I group all sound file definitions together? Or define some of them locally, if possible?

For example, suppose my application have some sound files, now I define all sound file references in a single class: public class SoundHelper{ public static Sound buttonSound=new Sound("(some url)...
1
vote
2answers
87 views

Architecture for slot machine game

I am building a slot machine game for a client (virtual money, not real-money gambling). They started out with a template game and hired me to reskin it and make "minor" changes for a "quick" release. ...
0
votes
1answer
26 views

Accessing an object accross different view functions

I am creating a web app for searching and buying bus tickets. I have created some objects like RequestedRoute, Passenger, and Ticket: class RequestedRoute: departure_station destination_station ...
1
vote
0answers
28 views

Splitting aggregate leads to inconsistencies in data

What I'm going for is something like GNUCash or any type of personal finance tracking software that looks similar to this: That is the main page listing all your accounts; then when you click an ...
1
vote
1answer
116 views

Why is using an internal attribute to filter objects considered OK, but when I use a map to filter based on attributes, it's considered a code smell?

A long time ago I asked about using an enum to essentially use as a poor version of instanceof to make decisions about an object. As stated in this answer: When your weapon types enum just mirrors ...
-1
votes
1answer
103 views

Have an object communicate with another object

I asked similar question earlier this morning, and for whatever reason, I'm not getting a complete answer to my question. I'll ask it a different way. I was attempting to understand Eric Lippert's ...
2
votes
2answers
86 views

Using a Collection with Attributes to Check and Make Decisions

I was reading on this SESE page about using a variable to indicate the object type, more specifically, an enum. The accepted answer states: When your weapon types enum just mirrors the class ...
-1
votes
0answers
42 views

how i read a code split into multiple classes and files? [duplicate]

I'm studying some Code languages OO and always see people saying its easy to put your code in multiple files and multiple classes instead to put everything in one single ROOT class/file. ok, I ...
1
vote
4answers
112 views

High class cohesion violates ubiquitous domain language

Originally posted at CodeReview, but it was brought up that this would be better posted here. The other question has been deleted. Creating some personal finance software, but running into an ...
2
votes
3answers
214 views

Why is the Command desing pattern useful for game AI?

I'm trying to learn the Command design pattern and apply it to the game I'm working on. First I read about the general implementation, and I feel like I understand it pretty well. Now I want to know ...
4
votes
1answer
324 views

Why do we imlpement the Command design pattern like this?

I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation. So I know we need to set the context by ...
0
votes
2answers
73 views

Appropriate design for restoration of previous states

This is a very common feature in software, and I am sure there is a whole deal written about it, but I really don't know what the technical term is, so here I am: I am talking about giving your ...
2
votes
0answers
33 views

Separate business logic from ORM models in SQLAlchemy

I have a Flask application with tens of complex models, almost all of them related to each other. A simple pseudo-schema of some of them: +----------------+ | FoodGroup | +-------+--------+ ...
1
vote
2answers
88 views

Performing serial communication in constructor to initialize an object

I have a class UnitInfo which represents a collection of unit information with methods to get the unit information in a structured way, such as a specific encoding, etc. This unit info consists of ...
1
vote
0answers
69 views

Expected behavior from client when thinking about design patterns?

I'm confused about the behavior I should expect from a client when thinking about design patterns. To be more precise, I'm reading the Head First Design Patterns book, and on the difference between ...
0
votes
2answers
65 views

Is it a good idea to let database surrogate key values spill out into other aspects of code (HTML, Controllers, Model, Repository layer)?

Is it acceptable to use id in HTML forms and subsequent code processing (controller, view, model, repository layers)? For example I need to show something like this on a web page: Select Motor ...
0
votes
1answer
78 views

Is this a 'proper' use of a trait in PHP?

In Laravel 5.6 an Illuminate\Database\Eloquent\Relations\BelongsTo relation was given the ability to support default models. This allows a model that will be returned if the relationship is empty. ...
1
vote
1answer
31 views

Using the objects retrieved at the time of request validation

I hope the question title already answers the subject here. Lets say I have a number of ids that needs to be validated in a request. Example: request uri: [POST] /album/{album_id}/song Request ...
0
votes
0answers
36 views

How to design my site solution correctly

I have a website that consists of users (more about the types below) and vacancies. Users can subscribe to vacancies and contact other certain types of users. While organizations and governments can ...
1
vote
0answers
66 views

Hierarchy of models while designing a client for a RESTful service

I am trying to write a client for a restful service. I am confused in designing the models. Below are the details: I have a Model named UnicastMessageRequest, it's definition is like this: ...
4
votes
2answers
164 views

Verifying Parameters in Constructor or Service

I was reading on this SO page about when to check parameters when constructing an object. The accepted answer suggests throwing the exception from the constructor so that an invalid object cannot be ...
3
votes
2answers
190 views

How is bad declare public static variable and use it in other classes?

GOAL: to have a main class which has some global variables which need to be modified by other classes. I have a class with a structure like below public class ClassName { public static ...
4
votes
3answers
365 views

Proper way to name a class which has just methods and not fields

GOAL: naming a class which has the responsibility to save data in Android database. The class structure is like this ClassName { public void saveSync(...){ /* implementation*/ } public ...
0
votes
1answer
36 views

How would you design the abstraction/class(es)/component(s) of a third-party service/api used in your application?

Lets say you were designing a Twitter client for people with people could see tweets and post tweets? How would you design the twitter api abstraction? Many of the api wrappers I've seen feature an ...
4
votes
1answer
88 views

Repository that performs API calls internally - DDD

Please note: although my question relates to DDD, I am also interested in this from an architectural and OO design perspective. This question may also be a simple case of CQRS and/or interface ...
2
votes
1answer
129 views

OOP Encapsulation Philosophy

Is it fair to say that it is good practice to default everything to private up when defining a class? For example, for my public interface I would set my class something like this: class foo { ...
1
vote
1answer
91 views

What to do if some parameters become constants inside a particular class

I'm sure there's some programming paradigm to cover this case, but I can't find the correct wording for it, and therefore my Google-fu is worthless. I have a class called SimpleWorld that has methods,...
0
votes
1answer
30 views

If I need connection to get data, then display the data at controller A, should I “Connect->To controller A”, or “To controller A->Connect”?

For example, suppose I have a shopping app, which has a user info page to show user info: class UserInfoController{ toPurchaseRecord(){ } } and a purchase record page to show purchase record,...
0
votes
2answers
104 views

Design Pattern to extract arbitrary field from arbitrary file format

Lets say I have multiple file types: .json, .csv ... etc These file types come in different formats: Second json structure Extra column added to csv etc. I need to extract fields from these files;...
12
votes
4answers
565 views

struct with nonsensical default value

In my system I frequently operate with airport codes ("YYZ", "LAX", "SFO", etc.), they are always in the exact same format (3 letter, represented as uppercase). The system typically deals with 25-50 ...
2
votes
2answers
110 views

Strategy/domain object responsibilities

Assume we are in the world of car rental application :) Let's say that I have 3 types of cars with 2 categories of price: Car type Price category ------------------------------ Sport ...
2
votes
3answers
475 views

What is the name of this pattern (if any)?

There's a sort of pattern that I've sort of stumbled myself into "discovering" that seems extremely useful, but I've never seen it described before. It's sort of a way of achieving inheritance through ...
6
votes
4answers
246 views

Passing around large value objects vs converting to smaller value objects

Let's say I have a project that needs to do the following: Multiple calls to read from the database where each call is a different query and returns back a value object (just has getters/setters). ...
-2
votes
1answer
55 views

Using a class as an attribute in another class or just one value?

I have a PHP script which has a group class and a component class. Each group consists of several components. My group has attributes groupName, groupId and componentList. My component has a ...
2
votes
5answers
152 views

Is a point drawn on a canvas considered an entity in domain driven design?

I'm reading on DDD and came across this excerpt: Let’s consider a drawing application. The user is presented a canvas and he can draw any points and lines of any thickness, style and color. It is ...
1
vote
1answer
46 views

Creating objects from a class/classes with different fixed values which can be easily expandable by a user

I am creating a program, and I would like to know the best practice for creating a class which defines different fuel types For instance, I have the following class that I have written in python: ...