instruction
stringlengths
34
19.9k
I have an MVC 4 based web app. Where I provide 2 login types, 1. Employee and 2. Customer. With Customer login, I present a dashboard and other stuff, about his orders, etc. With Employee login, I allow the employee to search for his customers and provide the ability to carry out certain customer specific tasks. It is ...
We are working on a integration between two large systems. System A is a database with employee data, and System B is an external system that is used for the daily contact with the customers (i.e meetings, locationdata,work order,work status, and so on). We will deploy a ESB in the middle. There are 3 instances of Syst...
I have created a library in Python that contains functions for accessing a database. This is a wrapper library around a third party application database, written due to the fact that the third party application does not offer a decent API. Now I originally let each function open a database connection for the duration o...
Well, there is lot of discussion about implementing 3 (or 2 stacks) in a single array. But whats the real need or application for implementing stacks like that? Can't we allot memory as 3 separate stacks [array] itself? Anyway we are alloting array[size * 3] in that single array. some links that discuss some: Use an a...
If a dynamic library exports the address to a global variable defined within the library, how are accesses to that variable translated during dynamic linking so that a running application can interact with it?
Many people consider exceptions to be a problem because they create invisible paths through your code. For example in this snippet: function writeToFile(text, filename): filehandle = open(filename) foreach line in text: filehandle.write(line) filehandle.close() The write method could throw an Exception. In t...
I've been working as an app developer for a year and a half now (not long I know), and I've just been given my first big project. Needless to say it didn't go very smoothly, so I sought advice from a senior programmer involved in the project about how to approach it. He said that I had drastically been over thinking t...
I have seen the words Fetch and Select used seemingly interchangeably when naming data access layer methods (ex. Person.Select or Person.Fetch). Which one is correct? My instinct is that the point of the data access layer is to abstract data access and thus the term Fetch would be more of an abstraction perhaps tha...
Im building small web-service which will provide my users with data through API. Also, some data will be available right on my website. The question is about how to use my own API? Should my website make a query to, for example, http://website.com/api/users/?format=json and then render data? Because I can use standard ...
I'm setting up some requirements for a software extension and try to use user stories to describe what I want to achieve. As a creator I want to add a new entry, to let users access it through the main page. I have the idea of adding an entry via Drag&Drop. My company has some guidelines, to have every command always...
I have a class (Timer) with an array list of Timable objects. Timeable is an interface. There is some specific functionality that I need for the Trigger class (implements Timable), which has a reference called target. A lot of methods need to search through the Timer array for Trigger objects with a certain target. Wh...
A common problem in my very small team workflow is handling merges from trunk/stable repositories up to feature branches which are ahead of the trunk or stable versions, but which need to track the changes in the trunk and stable versions. We are using mercurial, but any DVCS would perhaps have a similar workflow, incl...
I know that there are some other questions about C++ refactoring, but none satisfies my needs. I have a background in Java and Python programming, but now I'm approaching C++. I've read (and absolutely love) books about agile coding, test-driven development (TDD), refactoring, etc. The first that comes in my mind is "C...
I am learning Android programming and right now and i'm reading about fragments. I understand what fragments are, but either the tutorial is missing some steps or i'm missing something. So my question is when developing an Android UI, what are the benefits, if any, to using fragments as apposed to single page layouts? ...
Occasionally, I'm confronted with the problem that I have to provide some constructors in order to initialize objects with different sets of data. These sets can be mathematically transformed into each other, for example: public Element(int x, int y, int width, int height) { setValues(width,...
I have around 200 million new objects coming in, and a 90 day retention policy, so that leaves me with 18 billion records to be stored in the form of key-value pairs. Key and value both will be a string. It is basically a mapping between a unique identifier for the object in the application to the unique identifier for...
I am about to embark on a redesign of an application, one where querying the database is particularly annoying. I intend to redesign the database as much as possible but the data shape cannot change too much. The database has a main table and 10 other tables each representing a record type. The main table has all of t...
I'm looking for patterns or architectural guidance for an upcoming feature I'm designing. Basically, it's an export feature with multiple export targets, and I'm looking to find a way to make it generic enough where plugging in new export targets don't require a lot of core changes. By export targets, I'm simply referr...
It seems there is a lot of discussion on the web about the differences between these two paradigms, and how OOP is somewhat better than structured programming. But aren't they complementary? From my point of view one could organize his application following OOP principles and implement its logic using structured progra...
A group of us were wondering whether or not to go with CC0 or WTFPL because the CC0 explicitly states lack of liability. Does the WTFPL, if used properly, also free the author(s) from liability of usage?
In Mercurial you can close a branch like this: hg commit --close-branch, this means the the branch will not be listed anymore but will still exist, and can still be listed if you use hg branches --closed I have learned that in Git generally branches are not kept, they disappear, specially when doing fast-forward merges...
Let me explain our situation. We are small company with about 20+ staff and all the while we have been practicing the standard waterfall model with not much success (due to frequent changes of requirements and lack of direction). So one day our CTO came in and he briefed us about SCRUM and all of us were convinced that...
From the "Gang of Four" design patterns, there's the Factory method: class Factory(product) case product when a new A when b new B when c new C end new Factory(a) Why is this more useful than having three classes, a, b, and c and calling them individually?
This question is about the persistance of variables across different modules in nodejs when they don't directly "require" each other, but do "require" a common ancestor. It is also the generalised version of this stackoverflow question. Whilst I received an answer there that helped me solve my specific case, I'm still ...
I'm working on an assembly project and I need to write code to switch from text to VGA mode. This is fairly complex and requires setting up a lot of data, so I'd rather not write it myself. Fortunately I found a snippet of code on the internet that does exactly what I want. Unfortunately it does have a copyright notice...
I noticed that a lot of GitHub accounts only have repositories which are forked from other accounts. In addition the people who do this usually don't make any contributions to the forked repositories. I've heard of people collecting stamps and seashells, but why would anybody want to collect repositories? Personally I ...
I have a question regarding generalization. I know when it is needed to be done, but is it worth having an extra class for 1 field? e.g.: StatisticsCustomer has fields: Customer customer and int projectCount StatisticsCountry has fields: Country country and int projectCount What is best in this situation? Creating an e...
There was an application for PalmPilots that I liked back when PalmPilots were a thing. I want to recreate it (or at least what I remember of it) for modern mobile devices. The problem is, after scouring the internet for any information on the application or the original author, I am unable to find anything. I can't ev...
I have an opensource project currently under MIT license. I have received a request from a company to use my code for their commercial project without having to give any attribution or credit. To be honest, when I released the code, my sole intention was only to help a fellow programmer, and I didn't really think about...
In the same way that a publication table might relate to a person table via subscriptions, or a company table might relate to a person table via employee, I'm wondering if there is a descriptive way to relate a company table to a company_type table. Here are some rough (and simplified) examples of the relevant tables. ...
There are many comparative studies and available online when it comes to the runtime performance of applications built using one language or another. Some driven by corporations, some academic, some just personal experiment reports. We also get a decent share of comparative studies on side-effects of a programming lang...
I'm working on a Java Project, and I wrote a small plug-in to the existing project. I wrote it on my Mac(dev), QA is on Windows and Prod is on Unix. In the code I make specific API calls to a different program. On my mac though I'm just reading in a file. In Dev it is using windows file path to execute an external prog...
I have a peculiar problem. My application has different levels of authentication. One specific level of user (super user) needs to be able to use the application as another user (subordinate user) that has lower privileges. We decided that when the super user selects to be a subordinate user then another tab in the bro...
I have a javascript project which uses Grunt and several plug-ins such as: jshint qunit requirejs optimizer Not all of the developers run the grunt tasks locally (e.g. jshint, qunit), so they might not know if code they committed has issues. It's easy enough to set up a grunt watch task, but emailing the team upon er...
There are some (quite rare) cases where there is a risk of: reusing a variable which is not intended to be reused (see example 1), or using a variable instead of another, semantically close (see example 2). Example 1: var data = this.InitializeData(); if (this.IsConsistent(data, this.state)) { this.ETL.Process(da...
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...