Tagged Questions
-3
votes
1answer
102 views
Best practices: Number of return statements [duplicate]
I'd like to ask about best practices on return statements.
So, what would be more preferable, something like...
...
String r = null;
if(var != null) {
r = "NOT NULL!";
}
return r;
Or something ...
4
votes
2answers
214 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 ...
0
votes
1answer
51 views
MV(X) Patterns: How much nesting is too much? Is not enough?
Posts may be smaller than they appear! Skip the bulleted list.
Lemme Just Say...
I know that this is going to be largely (entirely...) opinion-based. Everyone has their own approach, and their own ...
1
vote
1answer
47 views
Where does my GetOrderNumber logic sit in a layered approach?
In a good layered design of an application, where would logic that generates an order number for an order entity sit?
The logic will need to lookup and increment either a sequence or a table with ...
-2
votes
2answers
75 views
multiple uses for original software [closed]
How does a programmer figure out multiple uses or applications for the original software he/she has written. I am an artist who has designed a RPG game with several different and separate applications ...
7
votes
3answers
259 views
How to perform input validation without exceptions or redundancy
When I'm trying to create an interface for a specific program I'm generally trying to avoid throwing exceptions that depend on non-validated input.
So what often happens is that I've thought of a ...
2
votes
1answer
141 views
Practices for navigating uncertainty in software design
Background:
So I'm trying to create my first game engine for learning purposes. After looking up a few articles I was able to design the beginning portions of my engine to at least get me going. My ...
4
votes
1answer
114 views
Contract interface/class with inner classes/interfaces
Brief description of my project structure.
I have some base classes like BaseView, BasePresenter ... .
Also my project consists of modules, module represents one complete part of the application.
...
2
votes
1answer
96 views
Future data integrity (n years)
So recently, I had a client ask me to restructure his Database hierarchy which consisted mainly of changing table names and column names and creating cross-references to stop red locks.
He later ...
0
votes
0answers
106 views
How to clarify the control flow when dealing with many callbacks?
Traditional programming could be done quite readable. Like this:
FUNCTION do_HTTP_request(url) {
if(!ask_user_if_he_wants_to_connect()) return;
if(!network_is_enabled()){
...
0
votes
0answers
87 views
Close-distance phone location network
I want to design a network in which multiple devices (phones or tablets) very close to each other (between 0.5-20m) will locate themselves in a map shown in each of the devices' App.
Known that:
...
2
votes
3answers
174 views
Data duplication, can it be an unavoidable practice in this example?
Say I have different employees of type Employee stored in a list inside a class SubCase.
public class SubCase{
protected ArrayList<Employee> employees;
...
}
SubCase represents a part ...
1
vote
3answers
2k views
Should I create .Clone() on a class or create a copy-constructor?
I'm quite unsure what I should use in C# - both should in theory do the same, but I think both are quite easely overseen. Or is there another possibility I have to take in consideration?
I know in C++...
15
votes
10answers
923 views
Do you generally send objects or their member variables into functions?
Which is generally accepted practice between these two cases:
function insertIntoDatabase(Account account, Otherthing thing) {
database.insertMethod(account.getId(), thing.getId(), thing....
1
vote
2answers
103 views
Is it a good idea having default static variables for new instances?
OK let's say I have something like this:
public class MyObject {
public static int DefaultValue = 9
private int _value = DefaultValue;
public int Value { get { return _value; } set { ...
0
votes
1answer
417 views
Best practices/patterns for generation PDF reports
I have PDF generation feature in my app. I am using iTextPDF for generating reports, so it works well. The problem is not exactly in pdf generation but in approach. Currently PDF generation code looks ...
1
vote
1answer
143 views
Better way to organize query methods in Android?
In my Android app I have:
A SQLiteHelper class that extends SQLIteOpenHelper, and takes care of things like table-creation and upgrades.
A SQLiteDatasource class that performs CRUD operations on the ...
3
votes
2answers
308 views
Using MVC style, where is the best place to put SQL functionality?
I am wondering about best practices here.
MVC (Model - View - Controller) patterns involve separating components of your program that model the data, manipulate those models, and display those ...
4
votes
1answer
61 views
What is the best pattern to define own type with definitive collection of values?
I want to define own data type, say a Digit, which would have definite type of values ( 0 to 9 ) and I'm struggling with defining this in a way it's practical. What's the best way (design pattern) to ...
1
vote
1answer
878 views
JavaScript & AngularJs Modules Implementation technique and structure
So Im building an app and I'm trying to implement the structure of the app so that its robust and scalable in future.
My app is mostly divided into JavaScript Modules (revealing pattern):
// filter....
2
votes
0answers
55 views
Should my application call statsd directly or should I call statsd based off logs?
I'm planning on incrementing counters in statsd based of various events within my application. I have logging in place for these events. So, from my viewpoint I have two options:
Update the ...
0
votes
2answers
154 views
Extensible way to create bash program
I have a bash script that should be extensible with additional functions with as little change to the script as possible.
The basic function is as follows. It loops through a list of files to check. ...
2
votes
3answers
453 views
Use of electronics in programming [closed]
Does a programmer need to have a deep understanding of digital electronics. Theoretical v/s practical. As what they teach us at college is pretty basic?
If yes, then do all kinds of programmers (...
1
vote
4answers
382 views
What's the alternative to DRY code when it requires too many parameters?
What is the best strategy for maintaining easy to follow code when keeping things DRY means you have to pass a lot of parameters to shared functions?
In my specific case, I have a grails based app, ...
1
vote
1answer
40 views
Filtering additions to a list
Hopefully Iʼm posting this in the right SX, and Iʼve tagged it correctly.
I have a legacy system that Iʼm making additions to which contains a custom list object.
This list object can contain two ...
2
votes
2answers
585 views
WCF service with methods to fetch data
I'm planning on building a WCF service that will fetch data entities from a Sql Server database. And I'm currently struggling with best practices issues.
The thing is that there's a few different ...
2
votes
1answer
359 views
Should all functions be fully self-contained (is it bad practice to share a variable between functions)?
There are two ways to do the same thing (pseudo code)
Define databaseHandle in the parent function, and use it as a global in this scope:
function API() {
function openDatabase() {
return ...
2
votes
1answer
194 views
How much trouble can the use of Singleton class as Model cause?
In my latest WPF applications I've been using a Singleton class, that I call Model, to contain all my application's logic, such as file reading, information handling, etc..
In the WPF Views or ...
17
votes
2answers
5k views
Role-based REST API?
I'm building a REST API for which several users with different roles will have access to the resources it contains.
To keep the scope simple let's take the "student/teacher/class" domain:
GET /...
2
votes
1answer
141 views
Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?
I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
1
vote
3answers
394 views
C# Subject Observer Architecture question
I'm making a C# application using the Subject Observer design pattern in a slightly different way.
I am passing the Provider Class, implementing IObservable (this has the OnNext() method that ...
3
votes
3answers
236 views
Development Time: sql in UI code vs domain model with datamapper
First, sorry for my English guys.
Currently this is my first programming job. I am labeled as the most incompetent programmer in my company that's because they measure the performance and ...
0
votes
1answer
248 views
Why use the Singleton pattern over class functions and fields? [duplicate]
I'm going to start by saying that I understand that programming in mostly class functions and variables can be harmful to object-orientation, and that most of the time an instance is preferred. I'll ...
0
votes
1answer
227 views
What is the correct way to bind few classes with similar functionality?
I want to do this in the right way to learn
I have a few classes which have only one method. For example:
public class RedColorText
{
public void AddRedColorText(string text)
{
//...
3
votes
3answers
2k views
Should I use foreign keys in my database if I use laravel?
I'm creating a website with Laravel for the first time. I checked relationships documentation today and it seems that Laravel just uses simple SQL queries.
class User extends Eloquent {
public ...
30
votes
5answers
2k views
Why do code-bases in n-tier development have an equal amount of, if not more, JavaScript code now?
I've been doing web programming for a long time now, and somewhere, I lost track of why we are doing what we are doing today (or how did we come to do things this way)?
I started out with basic ASP ...
2
votes
1answer
391 views
Program Architecture: How to manage objects that are interdependent
Consider the following case, image I making a simple chat program; I want it to be extensible such that it would be fair easy to add add different scripting and user interfaces.
I want the core ...
4
votes
2answers
225 views
How and Why should class modifiers enforce or prevent inheritance and the ability to override
This isn't really related to anything I am working on currently, its more of a question I really couldn't find an answer for.
Class modifiers like MustInherit or NotOverridable to me, seem like they ...
4
votes
1answer
290 views
Difference between patterns: Specification, Guarding, Conditions, Monads, Validation,
I'm currently trying to get my head around a few patterns (especially the ones mentioned in the title above) that are made to address different problems and are being used in different parts of the ...
4
votes
1answer
152 views
Is there a pattern or best practice for passing a reference type to multiple classes vs a static class?
My .NET application creates HTML files, and as such, the structure looks like
variable myData
BuildHomePage()
variable graph = new BuildGraphPage(myData)
variable table = BuildTablePage(myData)
...
0
votes
1answer
755 views
Best Practices For Temporary Scripts (Python)
I am running two separate programs which are similar enough that they share a lot of code. I run these programs often and after I evaluate the output. This is a very fluid process and everytime is ...
0
votes
1answer
168 views
Why is the “app” folder now a (more) common pattern in web projects?
It might be related to the Yeoman project, or they might have adopted this from somewhere else, but it seems to be the default for all of their generators. Aside from Yeoman generators I've also ...
2
votes
4answers
371 views
Callbacks: when to return value, and when to modify parameter?
When writing a callback, when is best to have the callback return a value, and when is it best to have the callback modify a parameter? Is there a difference?
For example, if we wanted to grab a list ...
1
vote
2answers
980 views
Why don't we completely de-couple frontend JS frameworks and backend APIs? [closed]
Whenever we implement a frontend framework in the likes of Backbone, AngularJS etc. there's an integration process involved with the backend technologies like NodeJS, Rails, Yii etc. (like setting up ...
2
votes
1answer
1k views
Methods for structuring JavaScript SDKs
I've built a REST API and have been using Backbone models throughout a couple different applications to communicate to it.
I would really like to build a single JS SDK that can be used in any ...
29
votes
6answers
5k views
Progressive Enhancement vs. Single Page Apps
I just got back from a conference in Boston called An Event Apart.
A really popular theme amongst the speakers was the idea of progressive enhancement - a site's content should go in the HTML, and ...
1
vote
1answer
115 views
How to deal with interactions between many objects
I've been working on a game in my spare time. I'm pretty much done defining the primitives and until today everything was pretty well segmented and encapsulated but now it's come time to implement ...
1
vote
1answer
83 views
Contradiction of layered design and global data access for analytics reporting
While developing an application (mobile app for Android), our team always strives to use best development practices such as interfaces, layering and separation of concerns.
When it comes to reporting ...
3
votes
1answer
117 views
Development console commands registration
I have a DevelopmentConsole class. I am making functionality to register console commands for the subsystems. I don't want the console to know about them but also I don't want them to contain a debug ...
5
votes
3answers
417 views
How is it called when you define constants that simply refer to a large namespace? [closed]
I am using JRuby.
I have many classes implemented in Java, and I want to create objects off of them in my Ruby scripts.
Suppose that I have a class Sprite in Java. In Ruby, to refer to it, I use the ...