Skip to main content

All Questions

4 votes
3 answers
1k views

Turning structural code into object oriented code

This is a bit experimentation from my part because I had written a lot of procedural code back in my school days hence I have trouble in thinking in OOP way i.e. to find proper classes and ...
2 votes
2 answers
4k views

Module with globals or Class with attributes?

Currently I'm working with a lot of modules where the original developers used global variables to control states and to exchange important information between functions, like so: STATE_VAR = 0 def ...
2 votes
5 answers
1k views

What should a constructor contain?

What should a constructor contain? In both cases, all three arguments are needed for the class to work. Which approach is better and why? 1) class Language { LanguageRepository ...
-1 votes
1 answer
241 views

How to avoid cyclic dependency in UI application

I'm developing an UI application where I ran into an issue with a cyclic dependency. Here is the simplified code, to explain the problem. #include <list> class UiStyle; UiStyle* CreateStyle(); ...
0 votes
1 answer
564 views

Using for_each instead of iterators to avoid iterator invalidation

I am writing a simple custom (special purpose) container and would like to allow for iteration over each element, however, avoid using iterators due to the problem of iterator invalidation. Instead of ...
2 votes
1 answer
118 views

Is it a good software engineering practice to store libraries as attributes of objects?

Suppose I initialize a library, say, in python object - #filename: file_A import file_ class A(): def __init__(self): self.pd = file_.pd self.np = file_.np And suppose the ...
1 vote
1 answer
618 views

Should the function that operates on the object return it?

Should the function that operates on the object return it? Shortened example: class Example1 { public function method($a, $b) { $result = new Result($a, $b); $this->...
-6 votes
1 answer
189 views

Finding object relationships [closed]

Description Its a follow up question of writing use cases. Taking from nouns defined in my user story and requirement I found the following candidates to be classes: User Question Session Attempt/...
4 votes
4 answers
539 views

Is it better to generate a large list during the constructor or when it's accessed?

I've got a class member function that generates a large list and puts it into a private member variable so it can be accessed through a getter. The generation of this list is a rather intensive ...
0 votes
2 answers
79 views

Class For Summarised List Of Complex Objects

Assume I have a class that represents a complex domain object with dozens of properties, such as a pension policy. The GUI lists all pensions in a summary table that only contains a small subset of ...
5 votes
2 answers
8k views

Design pattern for processing a huge CSV file -- Java

I am learning design patterns in Java and also working on a problem where I need to handle huge number of requests streaming into my program from a huge CSV file on the disk. Each CSV line is one ...
8 votes
10 answers
3k views

What should be first - functionality or design? [duplicate]

I've started reading a book from Head First series about OOP and Design. In a first chapter it is stated I have to worry about design of my application just after basic functionality is ready. Basic ...
2 votes
2 answers
2k views

Basic OOP Question for a Report

I'm in development of a sample project in Android for a friend's phone that keeps track of his sales. At first, one of the requirements was to create yearly reports of this sales data. This would be ...