Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
2
votes
1answer
35 views
Does this tkinter-based web browser widget use a well implemented class?
I have fully functional code in class format, and as far as I am aware from my previous question, it conforms to PEP 8 and the code logic and implementation is suitably pythonic. My main concerns here ...
10
votes
3answers
82 views
Design pattern for implementing multiple data sources
I've written a program to populate a particular object from multiple data sources, however I'm not convinced I'm going about this in the right way:
I have no idea which (if any) design pattern I ...
11
votes
4answers
2k views
Simple card game to learn OOP
My goal was to get my hands dirty in OOP by designing and using classes and getting started with inheritance and other OOP concepts.
I have written a very small code to play a card Game called ...
-1
votes
0answers
22 views
MVC in PHP: store and verify user input [on hold]
I'm trying to write an MVC script in PHP.
I've an object, e.g. a car, that can be booked. I created a class "car" and a child class "carEdit". In carEdit the controller can easily store and verify ...
11
votes
3answers
491 views
Interview Review - SOLID Principle and TDD
I had a small technical C# task using SOILD principle and TDD. But I failed to prove my coding skill through the test.
Can anyone offer any small advice for me? I am really eager to learn what my ...
5
votes
1answer
63 views
Case study with a biological populations. A list of lists of lists
I have a population (Pop) which has an attribute which is a list of individuals (Ind) where each individual has an attribute which is a list of chromosomes (Chromo). Each chromosome is a list of ...
7
votes
1answer
88 views
Drawing a triangle and some concentric circles
For class, I had to use Java to draw a triangle and some concentric circles. Here's my code (questions follow):
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class ...
6
votes
1answer
52 views
How should I implement my domain model?
My domain model consists mostly of simple DTOs, i.e. 'Data Transfer Objects' which this article distinguishes from 'Plain Old C# Objects', like this one:
public class Settings
{
public bool ...
9
votes
4answers
703 views
Human class implementation
I just want an indication as to whether or not I'm on the right track regarding PHP OOP, at least on a basic level. Positive criticism welcome.
P.S. Excuse the visuals of the code. This is how I ...
8
votes
3answers
116 views
Counting words / lines in Ruby - more compact / idiomatic way?
I solved this problem in Ruby:
Write an utility that takes 3 command-line parameters P1, P2 and P3.
P3 is OPTIONAL (see below) P1 is always a file path/name. P2 can take
the values:
...
0
votes
0answers
19 views
Object Calistenics - Reducing to two attributes [closed]
I'm refactoring an expense tracker system using Object Calisthenics. I'm able to bring my Class down to five attributes. How do I go forward from here?
This is my class right now.
public class ...
3
votes
1answer
48 views
PHP class design with methods requiring database access
I've been a procedural PHP programmer for a long time but I'm getting to learn OOP and would like some advice. I'm designing a class which currently is composed mainly of simple getters/setters, but ...
0
votes
0answers
15 views
Passing an object to the view in CodeIgniter
I'm trying to use an object and persist it into the data base.
I created a class in the library's folder.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class ...
3
votes
0answers
38 views
OpenGL object wrapped in a Qt widget
I have this object 'wrapper' class, which I will use to implement my Qt OpenGL scene. It is working, but I am looking for a way to:
improve the API
remove extra OpenGL calls
optimize it.
I know ...
2
votes
1answer
71 views
A File Collector
I'm writing an Object Oriented package and one problem I am trying to solve is a class that will get all php files in a particular directory and instantiate the classes but not abstracts or interface ...
3
votes
1answer
93 views
Making this Pygame code object-oriented
PYTHON 2.7-
I want to make my code OOP. I also want feedback from you on correctness, tidiness, design patterns and so on.
Here's the download link. It's not permanent but it's the best I have ...
0
votes
0answers
35 views
How to display domain object summary information efficiently when there are many types? [migrated]
I've provided only simplified code as it's more of an abstract design question.
So I have many, many nested business/domain event objects, e.g.
public class Event
{
//bunch of properties and ...
9
votes
3answers
122 views
Basic bingo game in Java
I've recently wrote a simple bingo game in Java to refresh myself in oop principals I have not touched in quite a while. I feel like I have accomplished this, but I would like to learn as much as ...
2
votes
1answer
41 views
Backend interface VS hard contract
Here is an API for using a warehouse:
public static class WarehouseClient
{
event Action<IWarehouse> WarehouseCreated;
}
public interface IWarehouse
{
event ...
3
votes
2answers
111 views
PHP Weather class
I am kind of new to object orientation in PHP and I need some experts feedback.
This class fetches the weather from this URL.
It grabs the weather, temperature and an icon from the current hour.
...
8
votes
3answers
192 views
Model cars as classes
I am learning about object oriented programming in Python using classes. I have attached an image of what I had in mind when structuring my classes. This is supposed script model cars. I want to know ...
8
votes
2answers
176 views
Implementation of the Strategy Pattern using an interface, abstract class and delegate
The following class was designed to help create a more detailed error message than what's provided by the repository when a user tries to insert text into a column that is > the column max length. The ...
10
votes
2answers
206 views
Multi-language website management
I have just started to use PHP OOP and I would like to write a class to make a multi-language website. I started from this but I wanted to use OOP so I came up with this:
Language.php
<?php
...
1
vote
1answer
95 views
Using a singleton class to get and set program wide settings
The following code works and does what I want, but I'd like to confirm I'm using this OOP concept correctly. I'm using the following class to get and set some configuration parameters for my program. ...
3
votes
1answer
64 views
Throw an exception to control the flow of code execution
There is a recommendation not to use an Exception to control the flow of execution. This gives me a reason for doubt when I do something like this:
public void initApplication(String input) {
...
3
votes
1answer
80 views
Use of the composite pattern
Assume the following requirements:
Is it a good idea to use the Composite design-pattern for this, taking into account that there will be:
Only 1 TestPlan
a TestPlan can only have TestSequences
a ...
0
votes
1answer
59 views
Review of my PHP Wrapper around Third Party Soap API
I have written a wrapper for Soap based 3rd party web service.
https://gist.github.com/veganista/bd940750d9e240e63b89
I'm pretty happy with it so far (I think, anyway). It's only a small sub-set of ...
4
votes
1answer
83 views
Simple Java class to represent progress
Progress class was written using TDD.
Interface of this class (pseudo-code):
class Progress
constructor(title, progressLength)
getTitle() : String
getLength() : int
...
0
votes
1answer
71 views
Writing a static Log class for PHP
I wanted to write a simple Log class for PHP, I use ajax calls with AngularJS and often return the log in an array
Example:
$return['data'] = $returnedDataArray;
$return['log'] = $logDataArray;
...
1
vote
0answers
44 views
How can I tackle this OOP design flaw in my Minesweeper Solver? [closed]
Here is the BitBucket git source code: https://bitbucket.org/tgharib/programs/src/c18f655b44b0/C%23/MinesweeperSolver/?at=master
Here are the main classes that I am focusing on:
public static class ...
3
votes
1answer
62 views
How do I avoid explicit type switching when operation based on state?
I've encountered a problem that I have to solve using dynamic_cast to invoke different functions, depending on the type of class State family.
I was re-factoring a Parser I wrote before, from a ...
4
votes
2answers
63 views
Review of java interface for constructing brain model
I have built a partial human brain model and the following is an example of how I use all the classes. I was wondering if anyone could critique my implementation strategies because I feel like the ...
3
votes
2answers
57 views
Constructing a binary tree in java
I am constructing a binary tree. Let me know if this is a right way to do it. If not please tell me how to?? I could not find a proper link where constructing a general binary tree has been coded. ...
3
votes
2answers
75 views
Structure of API wrapper
I'm building an API wrapper for a bookkeeping SOAP API.
I have some questions regarding bast practice for structure of the wrapper and for error handling.
For now i've structured it like this:
...
5
votes
7answers
304 views
One instance per method call or multiple method call per instance
I have the following class designs, and I'm looking for the best practices, aligned to the OOP design principles/patterns.
The ParameterParser will be used inside a foreach block through 10 items ...
2
votes
1answer
58 views
Using types in F#
I've played with F# for over a year, but I've only recently begun tentatively using it for professional work. I'm concerned that my c-style OOP principles are blinding me to the advantages of a ...
5
votes
1answer
180 views
Could this depth system for a game be improved?
I am still new to C++ and don't have a great insight on my coding yet, so I would be very grateful to anyone and everyone that gives advice.
Also, this code is meant to: keep all of my objects in an ...
2
votes
1answer
84 views
Best design pattern to approach http handler with multiple methods
I'm building an http handler at work which has about 6 methods and I'm trying to figure out what design pattern will work the best for my needs:
What's done already (Only an example to make this more ...
0
votes
2answers
214 views
PHP starting OOP MySQLi singleton
this is my first post on the whole StackExchange network, so I might make some mistakes. And I'm also spanish spearker, so I'll probably have mistakes in my writting too..
Context: I'm starting with ...
3
votes
2answers
139 views
Learning OOP javascript - critique my class that creates a 'favourites' list
I'm trying to improve my javascript coding style and want to start writing my code more object-oriented. The code below is getting a JSON-stringified list of locations from a cookie and appending a li ...
7
votes
5answers
481 views
Is `if( hidden ) return;` an antipattern?
Sometimes, when you're doing something like displaying a bunch of elements, you can avoid running a function entirely if an object is hidden.
So you can either write the check from the loop:
for( ...
2
votes
1answer
44 views
Class method with begin transaction and return errors
I've created a method which is useful for executing multiple queries, and it works perfectly. Is this a good way to handle this?
public function foo($rQuery)
{
try {
...
2
votes
1answer
119 views
Is my JavaScript OOP style correct?
I have done the following code for testing a web-service.
Is my style correct for using OOP in JavaScript?
<script>
function Ajax() {
var Base = {
...
5
votes
1answer
43 views
Object construction differences
Whenever I create a Javascript "class" I do something like this:
// Definition
function MyObject() {
this.id = 0;
this.legs = 2;
}
MyObject.prototype = {
walk: function() {
// Do ...
1
vote
4answers
159 views
Polishing and re-designing C code to C++ OOP principles [closed]
I would like to ask a question that many of you may find naive, so excuse me for that. I am coding a program that so far it has been built step-by-step while reading something like a manual, so it is ...
4
votes
2answers
113 views
PHP Cron wrapper
I attempt to create a reusable and scalable Cron Wrapper in PHP.
I'm at the begining of the project and I wanted have some tips/ critics / improvments to make before going too far.
The final ...
2
votes
3answers
136 views
Clear ArrayList
I create class level static ArrayList by the following line.
static ArrayList<Student> studentList = null;
Then I create and fill ArrayList with some objects inside a function.
studentList = ...
2
votes
3answers
78 views
Refactor if statement with object-oriented style
I've this block of code:
Edit: more accurate code:
public void Execute()
{
...
var memo = BL.GetMemo();
...
if (memo.testCond1()) //like memo.isLongText()
doSomething();
...
2
votes
1answer
111 views
Searching over more models rails
I'm trying to implement search over two models. In this example Book and Article. Here are the attributes from both of these :
Article(id: integer, magazine: string, title: string, body: text, ...
5
votes
3answers
97 views
Object inheritance
I have written some example code to test object inheritance, but I'm not sure if it's really the best way for an object to inherit another's functions (like Java's extends).
function Class() {
...