instruction
stringlengths
34
19.9k
I might be misunderstanding MVC, so forgive me if that is the case. This is my program structure (Java/Swing): I have a JTable (View) that is pointed to by a custom linked list (Model). When the user tries to add something to the JTable, the action listener (Controller) updates the linked list (Model) which updates the...
The situation: In my program, there are a list of cues. To call a cue at a certain time, there are objects called Triggers. Cues have many public methods that allow them, among other things, to be "fired" (which causes them to perform an action). Triggers "fire" cues when they are activated. They do this by taking a re...
Does anyone have suggestions for naming conventions for different types of functions, particularly wrapper functions that need to connect to and disconnect from the database vs. wrapper functions that are passed a db link and don't need to connect and disconnect? The project on which I am working has these types of fun...
I am currently working on refactoring a summer camp registration system to include some new features and will also be using it as the basis for a new after-school class registration system. For this new version of the system, I want to start out by writing use case descriptions for the registration process (and ultimat...
I'm in a software engineering class and I want to practice some skills on the most basic case possible : tic tac toe. I know this is overkill but I want to do it in "proper" OOP. I designed a class diagram for it but there is one point where I don't clearly see what would be the best design decision. ("Joueur" means "...
I'm writing a small program that I want to be able to link with other programs. I also intend to run it from a command line interface, and maybe later with a GUI interface. How could distribution and reuse flexibility be hurt by linking my program as a static or dynamic library? Distribute it as a library and Dynami...
My Android application is almost done and I spend much time creating a set of very precise help pages in HTML that I display using WebViews. I am now ready for the next step, which is i18n. Translating my app is no problem, the strings.xml is not that long and I can easily ask friends to translate it. My problem is abo...
Where I work it is a common practice to create a separate for JPA entities and a project for the web application (the WAR). So basically you have (at least) two project for each application - appJPA and appWEB. The people who started this convention are no longer there, so I have been wondering about the benefit of ha...
I'm an experienced C# developer. I've created a couple Windows Phone apps and a Windows 8 app but have wanted to develop for iOS too. What I'm thinking is adding the following equipment and software to make this possible: MacBook Air - necessary to compile/deploy to Apple's App Store and for some development tasks, as...
I am looking to use a javascript libray licensed under the LGPL license v3. From what I have read so far, I understand that If I do not make any modifications to the library, I can use the library without any restrictions. But if I modify the library, I need to make the modified version available to the end users and ...
We all know and love that function calls are usually implemented using the stack; there are frames, return addresses, parameters, the whole lot. However, the stack is an implementation detail: calling conventions may do different things (i.e. x86 fastcall uses (some) registers, MIPS and followers use register windows,...
My question has to do with JavaScript security. Imagine an authentication system where you're using a JavaScript framework like Backbone or AngularJS, and you need secure endpoints. That's not a problem, as the server always has the last word and will check if you're authorized to do what you want. But what if you need...
I've been looking into using the Typhoon framework for dependency injection this week. I get that separating the construction of objects is beneficial for replacing arbitrary components with mocks during unit testing, and so far I have seen benefits from this alone. But I cannot help but think that where before I had a...
I understand PKI well from a conceptual point of view - i.e. private keys/public keys - the math behind them, use of hash & encryption to sign a certificate, Digital Signing of Transactions or Documents etc. I have also worked on projects where openssl C libraries were used with certs for securing communication and aut...
I would like to monitor the filesystem in python, so that my application gets warned of the new file addition, file removal, or file change. Once the file is detected, the application starts extracting the contained data through various plugins. The problem is that I am dealing with big files, and when the user starts ...
Me and a friend of mine were discussing yesterday about differences between writing a large C++ software and understanding it as a new recruit. Is it possible that since a software gets done one line at a time and this process resembles how we (humans) learn things and build a thing on top of another one, writing a lar...
My goal is to stream a video from my pc, to a smartphone. However, i want the latency between us to be minimal. VIDEO -> ENCODING -> TRANSFER -> DECODING -> VIDEO I already know that the transfer will take approximately 50ms. What i want to know is different methods of encoding/decoding and how fast they are. The decod...
As the title says, I would like to write a HTTP server. My question is this, how do I do this? I know this sounds VERY general and too "high level", but there is a method to my madness. An answer to this question should be, I believe, language agnostic; meaning, no matter what language I use (e.g., C, C++, Java, etc.) ...
I am writing a program using VBA because its readily available, the code will be available to Cracks even though I password protect it. I knew this when I chose VBA because portability is more important than protection. My question relates to copyright, I put copyright and my name in the code and on the spread sheet to...
I just started at a company and one of the style comments at my first code review was that the return type and method name should be on different lines. For example, this void foo() { } should be this void foo() { } I've always used the first style, and I was wondering if there is any reason other than personal prefe...
I have often wondered why strict parsing was not chosen when creating HTML. For most of the Internet history, browsers have accepted any kind of markup and tried their best to parse it. The process degrades performance, permits people to write gibberish, and makes it difficult discontinue obsolete features. Is there a ...
I have a application which requires me to save data to a database not located on the users computer. Which approach is the best to save and access data for this scenario? Normally I would use Entity Framework and MS Sql Server but this seems not to a options for me with windows store apps.
We have three different networks. Regular, Trusted, Secure. Regular has access to the internet and trusted. Trusted has access to regular, internet and Secure. Secure has access to Trusted. We used to have a local SMTP server but the powers that be decided to move it, externally. Now the secure network does not have a...
I have an MVC web app that's wired against PostgreSQL. The DB uses the full gamut of various referential constraints to ensure referential integrity, as opposed to say the Rails approach, where you try to do most of the checks in the model logic. Also, by choice, I'm not using an ORM, I'm writing the SQL statements by ...
I create web applications most in RoR and PHP. About a year ago a company wanted to use my app but in a stand alone browser window in Linux, so I wrote one in python using webkit, locked it down to just accessing the target web app, easily done. Now what options do I have to do the same for Windows? I want basic brows...
I am currently building a Web application using a LAMP stack that relies on Javascript on the front end. As the app grows and expands, I naturally plan to expand and change the javascript files. I'm concerned that many of our users' computers will cache the files (which I usually want) but I want to be proactive to mak...
I'm in the process of developing a scalable proxy (Linux/C/C++, Nginx modules or custom HTTP server) handling incoming HTTP requests, and re-routing them to others locations based on parameters included in the incoming request itself (IP, time for example) or external factors (hence the use of an Nginx module able to r...
I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my program, I grouped them into: ListManager: object, which initializes them to the right values when it is constructed. The t...
I get how multiple processes can run on a single core by interleaving the processing. What I don't understand is how the operating system ensures that the program releases the processor after a certain amount of time. If only one program can run at a time, and the os allows a process to run, what's to prevent that proc...
According to the ECMAScript spec the integer part of a decimal number should be either zero or start with a non-zero digit. A hexadecimal value should start with 0x. Javascript, in the major browsers, extends EMCAScript to include octal numbers. These are determined by having a sequence of digits (from 0 to 7 inclusive...
I am creating a new project from scratch and have decided to use a 3-layer model. I am using: the 1st layer for business entities, the 2nd layer for business logic, and the 3rd layer for data logic layer. Do I need to create different projects for these different layers or do I need to create different folders in one...
Is that correct that a mutex object in Linux cannot be used for cross process synchronization as opposed to its Windows counterpart? If that is true - what was the idea to limit mutex synchronisation functionality on Linux?
I have a book which mentions: "There are many types of testing, including unit testing, integration testing, functional testing, system testing, performance testing, and acceptance testing". It is often noted that many developers carry out unit-testing only, or no testing at all. From the types of testing above, whic...
Is it looked down upon or bad to write multiple variable declarations on the same line? As in: boolean playMoreGames = true; int length; boolean win; int bodyparts; boolean contains; char blank = '-'; String word; Scan...
According to this answer every object in Java is of the same size? Is the answer talking about the object itself or the reference to the object? Here's the statement: every object size is rounded to 16 bytes in Hotspot, so an object with a single byte field will take up precisely the same space as a single object ...
In the interest of keeping my Controller's skinny, I put a headline method in a Model. # My Model class Property def headline "#{name} | #{address}" end end (Then, Property Controller for context...) # My Controller class PropertyController def show @property = Property.find(params[:id]) end end ...
I have a super class: TriggerManager with a subclass TimedTriggerManager. NOTE: I'm working in java TimedTriggerManager only deals with TimedTrigger s, a subclass of Trigger. TriggerManager references all Trigger objects. To modify the subclass (TimedTriggerManager) to only accept TimedTriggers into its accessors and m...
I grew up programming C++ and Java where everything was safe and beautiful. Compilers made sure to keep me in check if I ever strayed. Of course, everyone did a little Perl in college, but I didn't inhale. Kids these days are all about PHP on the backend and Javascript on the front. In trying to be hip, I do the same (...
Is it possible for a freelance programmer to use Open Source products under GNU Public License and make money given that he cannot stop his customers from freely distributing his products?
Whenever I am programming in an object-oriented language, I am always faced with what order and how to group the methods for an object. Are there any standards for this, or any suggestions?
I've been pondering for a while why Java and C# (and I'm sure other languages) default to reference equality for ==. In the programming I do (which certainly is only a small subset of programming problems), I almost always want logical equality when comparing objects instead of reference equality. I was trying to think...
This is a purely design question. I want to port a nice educational "game" Bug Brain to Java. In this game you design neural networks which consist of three elements: neurons, nodes and synapses. Neuron is used to perform some kind of processing on its input signals to produce the desired output; it can be connected wi...
I have been reading various Web application optimizing articles and many of them suggest to remove unused CSS rules. Currently, I have a page which has jQueryUI css, Bootstrap CSS, Datatables CSS and couple of more. All together they translate to about couple of thousands of rules ( my estimate ) and am quite sure I am...
The question motivations was depicted in the section below. There are many ways to make text italic, so, perhaps, there are more than one good "swap italics algorithm". The problem reveals some aditional dificulties in a XHTML code, and using the <i> tag, that must to be balanced. Example: <!-- original text: --> <...
I come from an object oriented background where I've learned that classes are or at least can be used to make a layer of abstraction that allows for easy recycling of code which can then either be used to make objects or be used in inheritance. Like for example I can have an animal class and then from that inherit cats...
The Spring framework supports the use of scripting languages (specifically JRuby, Groovy and BeanShell) whereby a script in any of these can call Java code and vice versa. I have read that a possible use of this feature is when some modules require frequent changes and it would allow to modify your application without ...
I got a bunch of questions to answer to prepare for an exam and this one I'm actually not sure what's the clear difference : "Explain the difference between designing software and designing physical products" I have an opinion on this, but the more I think about it the more it feels like there's no real difference exce...
I'm making a app which is based heavily on another application that serves a similar purpose. I'm not actually planning on selling it, but I'm wondering whether it would even be legal for me to sell it. I don't borrow graphics from the other application, but I have a very similar color scheme, virtually the same featur...
This probably been asked for but I can't google "How to make a compiler in C++" because I will just get "How to compile C++" as the results. Anyway, for my question, I'd like to make a simple programming language in C++. Now I understand basic file IO stuff but what I don't get is how to build a EXE. The problem here ...
Sometimes I run into a situation where I need to equate two new variables with an old one. Which of the following (if any) is a good practice (w.r.t. code readability or any other factor), under what conditions? a=b; c=b; or a=b; c=a; Note, a,b and c are just the names chosen in this example.
I have a single server with several clients. I want to push messages to a particular client at a given time. Clients should not polling to the server. what are good patterns and practices to solve this problem?
I'm developing a program using a library made by another programmer (he works in the same company). Recently I discovered a leak in the library, which happens under certain network conditions after a few hours of running. I filed a bug with description of conditions to make this leak happen. That developer answered th...
I'm reading Pro PHP and jQuery and want to rebuild the example. The author is creating a database connection class: class DB_Connect { protected $db; protected function __construct($dbo = NULL){ if (is_object($db)) { $this->db = $db; } else { // Constants are defined in /sys/config/...
Say I have created a web service based on RESTful APIs. Does it make sense to also provide users with a client library for the API in some select languages which are likely to be the most used ones? By client library, I mean a thin wrapper around all the API calls, so that the users can call methods in their language a...
My requirements are: To build an ASP.NET MVC web application to use Windows-based authentication, since all the users which will be accessing the application are our internal employees, and they have username and password on our company's Active Directory. So, as I understand, the Windows authentication inside ASP.NE...
I stumbled accross the SOLID principles. There is one burning question. Should I always use protocols? I never saw someone using them in the way that a Java developer would use them. I tried it in a demo project and ended up with a .h file for the protocol, another .h for the header. A .m file for the implementation a...
I am working on a personal project that works with databases, and in this project I have a set of classes that are similar, so they inherit from a common base class. The problem I am faced with is that I have this nagging feeling that the names of the classes that derive from the base class do not really reflect what t...
I have some legal questions regarding OpenJDKs source header: /* * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU Gener...
I seem to see this often enough in my code and others. There's nothing about it that seems horribly wrong, but it annoys me as it looks like it can be done better. I suppose a case statement, might make a little more sense, but often variable is a type that does not work well or at all with case statements (depending o...
I use 3 standard Spring MVC war, which share a common core (Services, DAO, and Models). The main problem is when I plan to deploy all the 3 wars on a same server. I have the Core Application Context instantiated 3 times. I know it's possible to share a common context using an EAR, but for scalability purposes I have to...
Background/Scenario I started writing a CLI application purely in C (my first proper C or C++ program that wasn't "Hello World" or a variation thereof). Around midway through I was working with "strings" of user input (char arrays) and I discovered the C++ string streamer object. I saw that I could save code using thes...
We are getting ready to port part of our app over to node.js, and are looking for a way to support s3 uploads and testing in our development environment. Right now we are thinking about setting up test buckets (ie 'myProductionBucket-test'), setting this in our dev environment configuration, and then creating a lifecy...
I'm trying to create a process for better understand what's happening in my code. I want to create metrics to automatically give my answers about simple or complex questions like: How many times a url was clicked? (how many requests arrived to a certain servlet method) How many times a certain user requested the same ...
I'm new to object-oriented programming, to java, and to programming in general, and as my first real project I'm trying to program the board game Monopoly. What I've got so far is an array that can store objects of the class Square (which has various subclasses, like properties, the railroads, chance cards etc.). Playe...
I've been learning both Common Lisp and Racket, and one thing that I consistently hear is that Racket is a much "smaller" language than Common Lisp. I was wondering what this really meant. As far as I can tell, the syntax for Common Lisp isn't that much bigger than for Racket. Basically, I'm wondering what exactly abou...
We currently have a monolithic Rails application that is really three separate applications that make use of the same data. In trying to figure out how to properly compartmentalize and break the mono-app into smaller pieces, it seems apparent that we need to have a central data service that the various pieces can commu...
I'm a php developer working on a startup, and my friend, my partner(a developer also), who is building the startup with me, is an asp.net/C# developer. How do we work together collaboratively, as we program in two distinct languages? I know you can use Mono http://mono-project.com to design android applications, (which...
I am trying to write a simple program that should allow a user to save and display sets of heterogeneous, but somehow related data. For clarity sake, I will use a representative example of vehicles. The program flow is like this: The program creates a Garage object, which is basically a class that can contain a list o...
I'm new to object-oriented programming, and I keep running into this issue. (I'm programming in Java) I've been a bit reluctant to ask about this, since it seems like such a basic issue, but I can't find any information on it, or questions about it here, and none of the textbooks I have read (on a quite basic level of ...
Recently had a doubt about how and where to test repository methods. Let the following situation: I have an interface IRepository like this: public interface IRepository<T> where T: class, IEntity { IQueryable<T> Query(Expression<Func<T, bool>> expression); // ... Omitted } And a generic implementation of ...
I've seen two styles of using sizeof for memory-related operations (such as in memset or malloc): sizeof(type), and sizeof variable or sizeof(variable) Which one would you prefer, or would you use a mix of the two styles, and when would you use each style? What are the pros and cons of each style and when you use the...
I understand PKI reasonably well from a conceptual point of view - i.e. private keys/public keys - the math behind them, use of hash & encryption to sign a certificate, Digital Signing of Transactions or Documents etc. I have also worked on projects where openssl C libraries were used with certs for securing communicat...
For example, let's say I want to build a game, and I have a limited knowledge of programming(some but definitely not enough). Should my first move be to design the game and then learn how to implement each separate part? Or should you learn a language really well before you design a game?
I have a bit of a challenge and I am not sure how to approach this. We have a very very large project (that is about 5 years old). The code base is HUGE so a full refactor is out of the question. What we will be doing is refactoring bits of code as we use those parts (this is backend code, which we will be using on a f...
I understand PKI reasonably well from a conceptual point of view - i.e. private keys/public keys - the math behind them, use of hash & encryption to sign a certificate, Digital Signing of Transactions or Documents etc. I have also worked on projects where openssl C libraries were used with certs for securing communicat...
We are in a process of redesigning our product code in such a way so as to support multitenancy. Currently the implementation is such that one product deployment caters to only one customer. Thus the application data corresponds to only one customer. This data (which is global wrt the application) is in the form of ...
I currently have a SQLite DB on my server that is needed by an android app I am currently developing. I download the DB to the android device using HTTP each time the contents are changed. Does anyone have any suggestions as to how to do this more efficient. ie. when the database gets large I don't want the android us...
The golden rule of code structuring is always said as splitting into many sub functions is a good thing. Though I noticed it becomes a problem in complex applications when a class of e.g. 10 bigger functions is split into a class with 50 functions. When development went so far, it becomes quite hard to understand the c...
I'm not so familiar with C++. Can someone please inform me what this lines does (in detail): auto add_element = [&rows,&cols,&values](size_t row, size_t col, double value) { rows.push_back(int(row)); cols.push_back(int(col)); values.push_back(value); }; Rows, cols, values are obvious vectors. Is this the s...
As a side project I wrote a simple macro in SAS to add syntatic sugar to SAS code. I hate how verbose SAS is sometimes! So my macro looks like this %macro md(code); /* expects a superquoted string */ * append a b; %if %lowcase(%scan(&code.,1)) = append %then %do; proc append base = %scan(&code.,2) dat...
I have just been reading through some of the white papers & examples from Microsoft "Roslyn" and the concept seems very interesting. From what I can tell, it opens up the black box that is the compiler and provides an interface that we can use to get information and metrics about code written in Visual Studio. Roslyn ...
A customer of my employer has recently requested new features for some legacy code, and since the authors of the program are no longer here, I've been assigned to implement the new features. I've been provided with some high-level documents that are mostly from early stages of the project: the project definition, black...
This last semester i've had lectures about OOP design, i understood most of what i was supposed to but there is something that i can't get right. I'm pretty sure that the models i create are wrong because they cannot be implemented. I wrote quite a lot because i can't tell where the problem is. This isn't homework , it...
Is it ethical to make a copy of my work's source code, for the sole purpose of my own reference? By reference, I mean as reference where I can refer to it about how I (and my teammates) implemented various design patterns, architecture, etc. It does not contain any trade secret, product, secret algorithm or anything li...
For advocacy purposes, I'm looking for a good example of some popular/widely-known closed-source and generally paid-for software application/package which uses dynamically linked LGPL-licensed libraries, and isn't shy of saying so in its installer dialogs or preferably in its "About" info and/or online documentation on...
I just ran into an odd scenario. I’m sure that I must have run into the same situation in the past and yet somehow not noticed it until now. I am writing a program that requires at least two command-line arguments. Dealing with this is simple enough, just check that there are sufficient arguments. For example: A: if (...
Let's say I have a boolean condition a AND b OR c AND d and I'm using a language where AND has a higher order of operation precedence than OR. I could write this line of code: If (a AND b) OR (c AND d) Then ... But really, that's equivalent to: If a AND b OR c AND d Then ... Are there compelling arguments in favor or...
I am making a voxel game like Minecraft. I am able to load chunks using multithreading with the code... for (int x = 0; x < WorldSettings.WORLD_WIDTH_IN_CHUNKS; x++) { for (int y = 0; y < WorldSettings.WORLD_LENGTH_IN_CHUNKS; y++) { chunks[x, y].BulidVertexData(); Thread.Sleep(50); } } this...
We are starting a total new Branch at our firm. I am usually developing database interfaces or internal server/client applications/tools for our company, but I never had to do something with hardware. Szenario My Boss want to sell a device, which has a touch-screen to set up the many, many features. However, the config...
I have been given the task of redeveloping an "in house" solution to make it expandable and easier to maintain and administer. The original solution had been hashed together over time using PHP as more requirements were added, and the need to expand is expected into the foreseeable future. The solution, gathers many di...
I've noticed an increase in mobile applications being released that offer high value features, but without any corresponding web based version. Was just reading about a new medical app for iPhone that allows doctors to share medical images, and had this idea been done 5 years ago it surely would have been a web applica...
I was thinking about this earlier today and figured I would get some input on the matter. When I develop applications I would usually have the Data Access Layer on another project, incase it could be re-used elsewhere in a similar manner in the future but also to allow updating the DAL without updating the UI layer. Wh...
I want to know how to manage a big project with many components with version control management system. In my current project there are 4 major parts. Web Server Admin console Platform. The web and server part uses 2 libraries that I wrote. In total there are 5 git repositories and 1 mercurial repository. The pro...
I'm currently designing an automated testing framework for doing embedded systems testing on an embedded Linux system. There exists an old system, but it is particularly hard to use, mainly because it wasn't designed as a framework and was originally designed to test one product only. What this means is that the framew...
I program in C and I believe I know the language well. I understand all the concepts and my problems never come from misuse of the language. I have problems because I always forget or oversee things. Setting a variable to zero, or generating a particular test case. I keep finding bugs in my code due to conditions I cou...
I've been reading articles such as this one that indicates web development has evolved to use JS frameworks. Where I work, we have a massive website with many existing web applications that are already established and are server side heavy. One article I read said that the DOM manipulation/jQuery method leads to unmai...
I am making a multiplayer game. Now I am trying to choose the technology to connect the android devices to the server. The clients run on Android, and the game is MMORPG. I would like to write the server in java. Right now I have only 3 ideas for it: 1) creating multithreading environment with plain java and sockets. I...
I'm new to git (and github). I work in Java and Python. Right now, I manage my projects in only one directory - let's call it Code and the folder is on my Desktop. I want to group my projects by the language I code in. So, I want: /Code/ ++ /Java/ ++ /Python/ I do not know if Git would be happy with this or not. If it...
About this function: org.apache.commons.lang3.BooleanUtils.isFalse(Boolean bool) and the similar isTrue, my co-work (less experienced) use it for every boolean in the code. I am trying to convince him that it is not a good practice because make the code confusing. In my POV, it should be used ONLY if the boolean to be ...
So, I've been developing some analytic software at my work and also have started to take more notice to analytics in general. For instance, I recently installed Google Analytics on my blog(which is custom and open source). I mostly make open source software outside of work, so I think it might be cool to be capable of...