All Questions
Tagged with python object-oriented
15 questions
14
votes
2
answers
3k
views
Object oriented vs vector based programming
I am torn between object oriented and vector based design. I love the abilities, structure and safety that objects give to the whole architecture. But at the same time, speed is very important to me, ...
9
votes
3
answers
27k
views
How to use multiple programming languages together in the same program? [closed]
Such a simple question, but I have not found a reasonable answer to this.
I currently program in Python, an interpreted language. I always hear of people using multiple languages in the same program? ...
41
votes
6
answers
11k
views
Should I create a class if my function is complex and has a lot of variables?
This question is somewhat language-agnostic, but not completely, since Object Oriented Programming (OOP) is different in, for example, Java, which doesn't have first-class functions, than it is in ...
21
votes
3
answers
24k
views
Why do you need "self." in Python to refer to instance variables?
I have been programming into a number of languages like Java, Ruby, Haskell and Python. I have to switch between many languages per day due to different projects I work on. Now, the issue is I often ...
20
votes
3
answers
19k
views
Differences between "Java OOP" and "Pythonic OOP"? [closed]
I started with ActionScript 2.0 and then went on with Java. I have learned, or at least used, a bunch of languages since then, including Python (probably my favorite).
I'm afraid that my style of ...
6
votes
4
answers
1k
views
Legitimate cases of having .equals() behaving inconsistently with .compareTo()?
Java documentation says it's "strongly recommended" to have them behaving consistently.
But are there legitimate cases of java/c#/python/etc Object.equals() method behaving inconsistently with the ...
6
votes
2
answers
3k
views
Is there such a thing as a workflow pattern? or how to do a workflow properly?
(and alternatives to a workflow engine)
Problem:
I have various inputs with various attributes.
For example {name: john, country: US} and {name: Jose, country: MX}
And I have the following workflows ...
4
votes
2
answers
1k
views
Why do we have mutator methods?
I'm switching from Java to Python and am having trouble understanding the @Property decorator. I realized in OOP languages (such as Java) I don't fully understand the point of mutator methods in the ...
3
votes
2
answers
2k
views
One boilerplate class or many similar classes?
Lets say I'm trying to model a variety of objects that are virtually identical, the only difference being their class variables. Am I better off creating one boilerplate class and just calling the ...
2
votes
1
answer
1k
views
In Python when is absolutely preferable to use a class instead of a module?
Python is the language I use most in this period.
My background in Java
Before start learning Python I have programmed in Java language. In Java all code is written inside the methods of a class and ...
1
vote
1
answer
198
views
Representing mathematical tree structures using software in a compact manner
In my work I frequently come across systems of interdependent equations. I have contrived a toy example as follows. The terminal values w, x, y and z are given:
e(y) = A+B
A(y) = x*log(y)+y^z
B(y) =...
1
vote
1
answer
352
views
Does creating a list in the constructor violate the guideline that a constructor shouldn't do work?
I was reading these pages (1,2,3), but I'm still unsure if this violates the guideline.
I have the following data being read from a website:
Date: July 13, 2018
Type: Partial Solar Eclipse
Location:...
0
votes
2
answers
512
views
Does Python have any features which can be used for encapsulating private data?
Usually in OOP world we are told that modularity is a good practice and keeping loose coupling between module is a great thing. Encapsulation helps us achieve this loose coupling.
In Java ...
-1
votes
2
answers
110
views
Object Oriented Python methods and their parameters
Let's say I have a class MyClass ... which has a data member x
class MyClass1 :
def __init__(self) :
self.x = 1
Also a method which does something with x
Should I pass self.x as a ...
-3
votes
2
answers
141
views
Seeking appropriate design pattern(s) to describe most function-based mathematical problems
I have been looking for a good, general design pattern to implement simple mathematical structures where functions have the following properties:
know which parameters they contain, parameters are "...