Tagged Questions

Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.

learn more… | top users | synonyms (1)

0
votes
0answers
23 views

OOP style and lexing

I'm not entirely clear how to do OOP cleanly. I have a Lexer class with a bunch of methods to retrieve different parts of a file, and some other helper methods. ...
2
votes
3answers
61 views

Is usage of friend class appropriate in this case?

I want to have a class that stores data from an input file, for use in a simulation program. It is like a struct but may require some small functions for accessors. A seperate class reads all the ...
6
votes
1answer
94 views

Does this simulation follow abstraction and encapsulation?

This below code implements a simulation of an ocean(as 2d-array of cells) which currently have Shark, fish or be Empty. User can run this simulation, as shown below: ...
0
votes
0answers
15 views

Python - call all methods of a class [on hold]

I'm wondering if my design is flawed or if I'm thinking this incorrectly: I have a class Lexer that has a number of methods. All methods are ...
3
votes
1answer
55 views

Getting a value from a database table dynamically

I am trying to create a forum using php in a MVC architecture. This is my database setup: Table: forum_categories ...
4
votes
2answers
53 views

LiveTime Object Literal

I have a website that retrieves time data from any given location on the world live. I wanted to be able to automatically change the time and not deal with the hassle of local client times. It's ...
-1
votes
0answers
25 views

How to deal with passing parameters to methods which call other methods? [on hold]

First, I am sorry for the vague title, I find it hard to think of a clear title that describes my question. Feel free to change the title of you know a better one. In my code I often have a situation ...
8
votes
1answer
166 views

Solar System model: Moving Space Balls

I have a model of the solar system that I'm working on at the moment. Now is the time to start cleaning my code up a little. Here's what I have so far: A main 'driver' method: ...
5
votes
2answers
55 views

Solving first- and second-degree degree polynomials

I was writing a bit of code and I was just wondering if I was doing it the right way. I know all the syntax is right and It all works perfectly. I was just wondering if I'm doing it the right way. ...
0
votes
0answers
6 views

Getter within loop returning null after assigning values [migrated]

I've got a slight problem with my program. Simply put, what I do is this: Choose the option to "Add a new Student record". When I try to display the newly added values (First Name, Last Name, ...
5
votes
3answers
83 views

Parameterised Constructors

Finally, Parameterised Constructors are possible in VBA. Background: One rainy day, I came up with an idea: take a static class and expose one property as default (like it was done in the Reverse ...
2
votes
1answer
33 views

Naming a function and its parameters for adjusting a queue

I have a function that takes all items in a queue and increments their order (used to allow insertion earlier in the queue). ...
3
votes
2answers
62 views

Can I further secure this blog post loading script?

The following code is developed around a mysql database where the posts table has 3 columns: post_ID, date and title. config.php holds the values for $dsn, ...
6
votes
5answers
145 views

DP solution to min triangle path

I am studying for interviews for various companies. I wrote a solution to this problem, but if an experience programmer looks at it I am sure there are certain areas the code can be made in to a more ...
1
vote
1answer
33 views

Orange Tree simulator

I'm practicing SOLID principles and the concept of making a clear distinction between an object's private and public interfaces. ...
5
votes
3answers
423 views

Trip Advisor - Train routes

Gives advice to the user on which trains to take to reach a destination ...
3
votes
1answer
89 views

Example String Class in C

I wrote this small example piece of OOP being implemented in pure C. I wanted it to be reviewed for the following points: Portability Performance And especially Usability "How does it look" ...
6
votes
1answer
71 views

Bowling scores in Ruby

A little while back, I wrote in a review of a Ruby bowling sim that I might try my hand at modelling the game myself, focussing on the funky "deferred scores" system. Since a2bfay, who posted the ...
7
votes
1answer
83 views

Multiplayer bowling in Ruby (follow-up: injection, single responsibility)

This is a multiplayer bowling simulator in Ruby. It allows for variable skill levels, and produces weighted random results for each player's rolls based on those skill settings. This is a complete ...
8
votes
2answers
86 views

Generating and calling code on the fly

Delegate This class module defines what I'm calling, in this context, a Delegate - here a function that can take a number of parameters, evaluate a result, and ...
5
votes
3answers
345 views

Would I be better off re-factoring out these switches, in this case?

After I completed writing this code, I started to wonder if the switches should be replaced with a more OOP approach. I originally picked the switch approach because there will never be anymore skill ...
2
votes
1answer
35 views

Optimizing mcrypt encryption class further

The following is a very simple implementation of an Encryption class using mcrypt whereby the functions encrypt and ...
18
votes
7answers
3k views

Basic OOP Poker - Deck, Cards and Hands

I decided it would be interesting to simulate a game of Poker. Baby steps at the moment, and eventually I'll attempt to turn it into a GUI. The code I have so far is very basic such as populating a ...
3
votes
2answers
64 views

Booking validation in a big if-elseif block

I have pasted a part of my event handler code block. I understand this code really looks like a mess specially the object that is created every time the message is changing. Is cleanup possible in ...
9
votes
2answers
117 views

PDO connection via INI parser classes

A few days ago I asked this question and I've got an answer to work with interfaces. I've tweaked around with this to get myself a INI parser class. ...
8
votes
1answer
155 views

Breadth First Search not SOLID enough

The following code has a modified version of the Breadth First Search algorithm. It not only visits the nodes, but keeps track of the paths, so I can output various messages later. I would like to ...
0
votes
0answers
45 views

Proper code structure to not pollute JavaScript global namespace and use proper encapsulation

I have a number of DHTMLX pages that I need to create and want to start structuring my JavaScript better so that I'm not polluting the global namespace. Take the following pseudocode: ...
4
votes
2answers
104 views

Accept an object and generate a email

I have a question regarding optimizing a php email class. It's basically a wrapper class than needs to be able to accept different objects and always output an email. I'm trying to make it generic, in ...
4
votes
1answer
44 views

Defining a JavaScript internal method that needs to be accessible from inside obj and out

I'm trying to fully grasp JavaScript inheritance and encapsulation. Take the following example (here is a Fiddle): ...
2
votes
2answers
68 views

RAII and code duplication in constructor/destructor

I have a class hierarchy similar to this: ...
1
vote
2answers
71 views

Multi Threaded Report Generation

I have a requirement where i have to generate some report basically read from db and write data to Excel. I want your help in reviewing following things in my code. Data Base Connection Multi ...
11
votes
1answer
92 views

Extensible logging - DatabaseLogger

Recently I wrote a logging API that features an ILogger interface. I wanted to extend my library with a DatabaseLogger ...
13
votes
1answer
91 views

Extensible logging

Whenever I need logging functionality in .net, I use a logging framework, such as NLog. Obviously there's no logging framework for vba, at least none that I know of. As much as I love using NLog, the ...
1
vote
1answer
68 views

Is this use of JavaScript prototype functions for attaching event listeners going to meet design goals?

Please provide a sanity check on my below JavaScript pattern to be used for a custom edit control. The goals are: Centralized code Avoid name collisions Minimize memory use (putting functions on ...
6
votes
3answers
146 views

Counting occurrences of different categories of characters

This is a sort of follow up to my previous question: Counting the number of character occurrences This time I have written code that still counts the number of different characters in a string, but ...
6
votes
1answer
83 views

Deleting a user from a database

I was hoping if anyone could tell me if I'm doing this correctly, I know there are other questions like this but everyone codes different and I just feel that I'm not doing this right. I'm trying to ...
2
votes
1answer
100 views

What could be bad from using this form of dependancy injection?

I have a custom framework that I am not sure if certain things I have applied are wrong and if so, just why. I am not well versed in any framework, so I was forced to use mine. Here is an example ...
9
votes
3answers
127 views

Ugly workaround to get the vbext_ProcKind of a procedure is breaking encapsulation

This is a follow up to Extending the VBAExtensibility Library. It turns out that code had a really nasty bug. Anytime vbeProcedure.StartLine got called, I was ...
3
votes
0answers
55 views

Universal Spreadsheet reader/writer

I have a project that reads spreadsheets as a rectangular list of lists (matrix) transforms the matrix and then writes it to another spreadsheet. I want to be able to read from and write to multiple ...
3
votes
3answers
139 views

Object Interaction in OOP (especially Python) [closed]

Say you have a number of similar objects (e.g. instances of the class Person). Each of these instances can belong to a number of Groups, also represented by a class. To stick with the examples of ...
0
votes
1answer
72 views

Aliasing utility class method in extended class

Consider this setup: ...
1
vote
2answers
161 views

Fractions in Java [closed]

Part I-IV recommend code changes as mentioned in link 1, for the initial code given at link 2. Can you please review the code changes for Part I-IV? Part I: Constructors (1 point) Modify the ...
4
votes
2answers
74 views

PHP Session Wrapper Class

I recently worked on a system for the company I work for and would love some feedback on the following class for managing sessions. I don't claim to be a PHP guru but I like to think I gave it a try! ...
8
votes
3answers
348 views

Singleton Database wrapper

Before everybody yells at me about why I wrote a PDO wrapper class, it's to avoid writing try/catch, ...
2
votes
1answer
40 views

User entity of my domain v2

I would appreciate a thorough review of my updated User entity class. It's still an anemic domain model, but behavior (like ...
3
votes
3answers
159 views

Is SList class an ADT?

As per the definition given in lecture, ADT is, With reference to this definition, I would like to call SList class an ADT following 6 invariants: Multiple ...
1
vote
2answers
51 views

Putting all desktop items into a new folder

I'm quite a newbie with Python, but I wanted to try my own little project, so I made a small script that puts all the desktop icons/folders into a newly created folder (called "Desktop1") if there are ...
6
votes
1answer
65 views

A hacked-up testing framework

Inspired by this post, I wanted to be able, in any vba project I could be working on, to create a test class and write test methods. Like this: ThisWorkbook Workbook | class module (client code) ...
2
votes
1answer
84 views

Encryption/decryption of a string with a salt

I have a new job coming up soon and want to increase my PHP knowledge. This is my first attempt at creating and using a class. I just want to know if it's the correct way to do things. It's very ...
1
vote
1answer
19 views

Create virtual host + MySQL tool

This tool adds a new OS user, create directories and configuration files for Apache + NGINX, MySQL (MariaDB) database and user. I tried to take into account the comments from my previous post. Hope - ...