I am going to be implementing a network protocol (specifically, SFTP) and I wondered if there are any general rules-of-thumb to follow?
At the moment it seems like a mammoth task and I'm at a loss as where to start.
I'm looking for:
Tips
Best practices
Possible design patterns
Experiences
Try to keep it applicable to network protoc...
I'm currently writing up a text document for a .NET solution that contains multiple projects and assemblies and I'm needing to communicate the relationship between the classes/interfaces/etc. so that others can understand how data needs to be "wired up" inside the application.
For example, I might need to say something like:
The MyS...
In my experience, most JS functions, constructor functions, or module-pattern functions, are declared as globals or are bound to a global namespace object. In any case, these identifiers are globally accessible.
From any line of code in your system you can have:
mod1 = somepackage.SomeModule(); // couple to me!
Here's a quick JS exa...
I'm working with Doctrine2 for the first time, but I think this question is generic enough to not be dependent on a specific ORM.
Should the entities in a Data Mapper pattern be aware - and use - the Mapper?
I have a few specific examples, but they all seem to boil down to the same general question.
If I'm dealing with data from an ...
I prefer coding standards to be logical. This is my argument for why the following set of standards are not.
I need to know one of two things: (1) why I'm wrong, or (2) how to convince my team to change them.
camelCase: Functions, class names, methods, and variables must be camelCase.
Makes it hard to differentiate between variable...
I'm looking for how to structure the layer of my app between the presentation layer and the model / business object layer. I see examples using Controller classes and others using Service classes. Are these the same things with different names for different methodologies, or is there a more fundamental difference?
Edit:
To put the que...
Hi, I have an abstract class called account which is as follows -
abstract class Account
{
private int number;
private String owner;
public Account(int accountNumber, String accountOwner)
{
number = accountNumber;
owner = accountOwner;
}
public int getAccountNumber(){ return number; }
publ...
Hey guys,
I'm looking for some thoughts on which design pattern(s) to use for my problem, regardless of language.
I am accessing three APIs that have different interfaces and functionality, but are all for the same purpose, returning information to me, in a uniform way, about the same kind of content -- blog authors.
Some APIs do exa...
My problem is with objInfo(). How can I return an object via a passed-in variable? I'm trying to namespace my code and use private/public vars.
Bonus Q: How would you otherwise improve the code?
// Namespace all my code
var bab = new function() {
// Declare cat object
function cat()
{
this.eyes = 2;
this.legs =...
You can create new objects, but when you've finished using them there's no real way to destroy them immediately as well?
Why didn't every OOP runtime implement such behaviour?
I'm sure we as developers could (often) organize for object instances to be destroyed when we've finished using them.
function work(){
var p1:Point = new Po...
I'm curious which programming tools have empowered you as the programmer the most. By empower I essentially mean tools have made complex tasks simpler (both conceptually and implementation wise). I am talking about Objective C and Cocoa primarily, although I suppose this question is rather language independent.
For instance, before I di...
Hi there,
I have the following code (taken from actual script):
$result=mysql_query($sql);
while($row=mysql_fetch_assoc($result))
{
$auth_token=$row['oauth_token'];
$auth_token_secret=$row['oauth_token_secret'];
$apiconn = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $auth_token, $auth_token_secret);
$API_result = $apiconn->pos...
Hi,
I am trying to write a program in object-oriented style. I have some confusions when coding the interaction between two objects.
Scenario:
Person (John) gives Person (Betty) $ 5.
Possible solutions (pseudo code):
A) John.pays(Betty, 5);
B) Betty.receives(John, 5);
C) Bank.transfer(John, Betty, 5);
D)
begin transaction:
John....
I would like to know in what scenarios you use encapsulation. The purpose of this question is collaborative. So feel free to share your own experience when the subject is encapsulation.
Some scenarios:
Calculated property
public class Order {
private List<ListItem> listItems = new ArrayList<ListItem>();
public double getTota...
You've probably heard of the Fat Model/Thin Controller vs. Thin Model/Fat Controller distinction. I recently heard that you can have something in between where some of the logic from the model goes into a service layer. How common is this? and do you know of (or can think of) any real examples that illustrate it?
...
What is the best way to define a method signature when you have to pass many values to a function and some of these may be optional. And in future, May be I have to pass more variables or subtract some passed values given to function.
For example: (phone and address are optional)
function addInfo( $name, $dob, $phone='', $address='' ) ...
I'm writing a Python program with a GUI built with the Tkinter module. I'm using a class to define the GUI because it makes it easier to pass commands to buttons and makes the whole thing a bit easier to understand.
The actual initialization of my GUI takes about 150 lines of code. To make this easier to understand, I've written the __i...
I'd like to start with a little background, in case anyone has any better ideas for design.
I'm looking to create a database class that connects to a database at construction. I would use functions to call the database, to get what I want. The database connection would be closed at destruction.
Since I'm connecting in construction, I'd...
I have been programming (as a job) for around 3-4 months now after having graduated from university studying computing.
At university I was taught object orientated programming and I felt I had a good grasp on this until I started working on real problems.
I just cant seem to do anything but come up with procedural code for solutions -...
I have been assigned the task of refactoring a legacy database application and I am trying to create objects that incapsulate the old code. It is the first time I use real OODesign, for now I just used OO to encapsulate some legacy login and refactor a subset of functionalities from an application. (Now it is the classic client server a...