instruction
stringlengths
34
19.9k
Background I recently developed, for two different projects, two web applications. The two followed quite different approaches. The first one was a classic inventory application (lists of stuff to view, select, edit.. very CRUD) and was developed with Razor and ASP.NET MVC: controller accepting requests, getting a mod...
I am writing some code in Python which checks for the validity of a license key after polling a server. If it is valid then the Python program in turn runs some bash scripts. How to create a combined binary of the python script (to check the license) and the bash script (which performs the task)? Here are what I thin...
I've been using MVC/MV* since I started actually organizing my code years ago. I've been using it so long that I can't even think of any other way to structure my code and every job I've had after being an intern was MVC based. My question is, what are the downfalls of MVC? In what cases would MVC be a bad choice for a...
In my job I deal with several projects at the same time (and who doesn't?). Sometimes I have to make changes to a project which I dealt with half a year ago or even longer. And it's hard to recollect the details about the project. I usually look for the modification dates of the files, then I start digging into my emai...
I am trying to write a program which make the following: ?- g([2,3, [22,[3],9] ,4,[5],99],X). X= [2,3,22,[3],9 ,4,5,99] so it searches for lists in the given list and replace it by their elements without brackets []. so I wrote this program: The first block just searches for the first element in the list which is lis...
I'm exploring options for running a small cloud Windows Server (either AWS EC2 Micro or Azure Extra Small). The server won't be hit very hard, but I need to run a simple relational database, which I'm expecting to be moderately sized - probably a few tables with a few hundred thousand records, and running a few thousan...
I'm working on my first ASP.NET project and I'm torn between using asp tags (<asp:SomeElement) everywhere or use some regular HTML for simple things that need no code behind, like fixed divs, static text, etc. I think it would be best to use ASP tags only for code behind and other dynamic stuff, whereas static elements...
There are so many Java technologies that it is difficult for me to know where to start. I understand JSP and Servlets. I know what http servers to use. Real basic stuff. What I don't understand is what I do after that? I don't want to create a bunch of jsp and servlets. That's not very different than what I have. ...
I have designed a simple website on paper. Now I want to produce a professional-looking document for my customer to approve. How can I do this? I've tried Visio, but it seems horribly overcomplicated and unsuitable for my purpose. I could describe what I've written in words in a Word document but that'd be much harder ...
We are implementing a matrix compression library based on a modified two dimensional grammar syntax. Now we have two approaches for our data types -which one will be better in case of memory usage? (we want to compress something ;)). The grammars contain NonTerminals with exactly 4 Productions or a Terminal on the righ...
We have what can be called a distributed application: One full-blown web app and a small REST service. Both must be separately deployable. Both access the same database schema (they actually share only two tables). The common functionality is encapsulated in a common artifact (a JAR file here, since it’s all Java). So ...
I'm new to developing software and have been handling feature requests for an internal web-app I built. Sometimes the feature requests are straight-forward and require minimal business logic for me to implement, so I talk to the person for a bit, write their requirements down, and get to work. However, I'm starting to...
I am beginner to Python and I really like it so far. One question that comes to my mind very often is if I need to understand and therefore learn the Internals of a programming language (as in my case Python). As you might know, Python itself is written in C. So my question is: How deep do have to dive into a programmi...
I'm developing desktop application in java/swing. I have a component that is registered as a subscriber to many panels and gets messages (my custom event) from them. That component is something like message tray. When there is a validation error or some kind of info message it's delivered from panel to that tray by my ...
While writing an EJB (deployed on WAS) that connects to a db, i have never needed to use JCA. But apparently JCA is the standard for connection to thrid party EIS (which includes database). So does the WAS implement JCA internally? Under what situation would the app develoepr need to use JCA related classes?
When we add .edmx files to a DLL, the physical size of the DLL increases. DLL's are loaded into memory. However, the .NET infrastructure with functionality such as JIT compilation and the GAC complicates things. Is it true that having a larger DLL automatically increase the memory requirements of an application? In...
This is the first time I will be delivering code for a freelance project (web-app), and, since I don't have much experience shipping code, I am having a hard time deciding whether my program is ready for deployment or not. My understanding is that a production-level code must have the following characteristics: Fault ...
When a dynamically linked library includes a global mutable variable, such as a container for state initialised when loading the library, how do references to that variable behave when running an application that links against it? Obviously the application cannot alter memory allocated to the dynamically-linked library...
First of all, in this question I'd like to stay away from the polemic on whether source code commenting is good or bad. I'm just trying to understand more clearly what people mean when they talk about comments that tell you WHY, WHAT or HOW. We often see guidelines like "Comments should tell you WHY; code itself should...
Using pointer, I am able to modify the private value of the class in the code below. Does it violate the C++ concept that private member can only be modified by member or friend functions? #include<iostream> using namespace std; class demo { private: int info; public: demo() ...
I am writing my first application for Android and will use the SQLite database so will be trying to limit the size as much as possible, but I think the question applies in general to database design. I am planning to store records that will have text and the date of creation. The app is a stand-alone app, i.e. it will ...
I am wondering why there is no markdown syntax for underline? I know that basic html tags can be embedded to achieve this but I am trying to understand why underline got omitted when bold and italics exists
I'm using python to do some research tasks. I have a class hierarchy for "tools", where each object is an instance of a particular tool. They all share some functionality and have many similarities in their states. Some of these tools can use one of several methods based on the tool object's current state. The specific...
Why is the Scala Option type not called Maybe, just as in Haskell? Maybe makes a lot more "semantic sense" to me, but maybe Option has different behaviour I am not aware of. Is there any particular reason why Option in Scala was not called Maybe?
At work, we develop a lot of our applications in SAS, from start to finish. One of the problems with this approach is that SAS is a very verbose language with very few language constructs; there is limited support for variables, very limited support for basic functions, and no such thing as classes. They have a concept...
I am handling a team of a few guys working on a software module in a large project. As per our estimates our module is getting delayed by a week. Since we can not have this delay, our client and our manager arrive at a decision that we need to work on few weekends (3-4) to try to finish the work. All members of the te...
I am really struggling with a problem where I need to "prune" down available scenarios to those that a user has defined as valid. Below is a small example of the problem I am trying to solve in .Net (C#). Given the levels / values shown below, the user could pick that there are only a few valid combinations, but if you...
I've posted questions pertaining to this issue before, but they've all tackled different aspects of the problem (Just so you know that I'm not reposting the same question to get more answers). So, in a nutshell, here is my problem: I have a Timeline class, which has-a Content interface member variable. The Timeline man...
I thought Doctrine 2 DBAL prepared statements were safe from SQLi. But I found this confusing bit in the docs: By default the Doctrine DBAL does no escaping. Escaping is a very tricky business to do automatically, therefore there is none by default. When you use the Doctrine DBAL as standalone, you have to take ...
I am looking all over internet to find a logic to convert an Algebraic Expression into a Binary Tree. I could only find ones where you first convert the algebra expression to postfix or prefix and then convert it to Binary Tree. I am just curious to know , if its possible. Any pointers to external links or logical answ...
Background: I was writing some code. It looked something like this: class X { private List<int> _myList = new List<int>(); public void MyMethod(int x) { _myList.Add(x); } } R# suggested that I make _myList readonly. I wasn't so sure, as though I technically could make it readonly, I think it wo...
This is not meant to start a religio-technical browser war - I still prefer Chrome, at least for now, but: Because of a perhaps Chrome-related problem with my web page (see also), I temporarily switched to IE (10) to see if it would also view the time value as invalid. However, I didn't even get to that point - IE stop...
I like IE's persnicketiness (the debugging tools that take you right to your code is even more user-friendly than what I've found in F12 Chrome Dev Tools), but why does it say, "'console' is undefined" re: this line of jQjuery: console.log("entered submit button click"); How could console be undefined? Neither Chrome ...
One programmer is testing and comparing the same application which uses the same database structure, and the same data, only in two separate databases, one with Oracle 8 and one with Oracle 9. The app runs a query with no ORDER BY clause. He claims that the ORDER-BY-less query should return the rows in the same order i...
I asked about Compiler interpretation of overriding vs overloading on StackOverflow, and got good answers, but this led me to another question that I'm not sure is appropriate for SO, but I think is for here. One should read the original question and accepted answer, but perhaps it's understandable just by looking at t...
Non-turing complete languages can solve every practical problem that a turing-complete language can. Also, they are much more analyzable than turing complete languages. The compiler can comprehend the program as a whole, predict/compute/cache every possible computation in advance, optimize it the most mathematically po...
I would like to be able to see what code in thousands of lines of source code is run most often and takes the longest. The purpose of this would be for optimization. Being able to see what parts of the code are run most often is important for optimization, because those parts are where I should focus to speed up. At th...
I have an object that I am downloading over HTTP, that has approximately 50 attributes. What is the proper way to store this information in Objective-C? Should I have an NSObject with a property for each attribute (if so, what would be a good way to initialize this object?)? Should I use an NSDictionary with 50 key-val...
Let's say you develop a software program for Windows in C#, then Joe Blow develops the same software program for Windows but instead codes it using C++. If Joe Blow were to sell that software program, what would determine who would get more money for it given the different languages? Assuming, both used the same licen...
On my current project I am responsible for the implementation of a service which involves the consumption of newly created RESTful APIs, documented as solely supporting JSON. The client consistently makes requests with the accept header of 'application/json' and content-type of 'application/json'. However some endpoin...
Have you had this problem? You are building a complex web application for a target market, and after a while you reach a point in complexity where you can't decide if you are building more than one product. A decision has to be made. Do you add features to turn it into a framework for multiple domains or do you resist ...
I've studied design pattern and oop principles, still feel that there is something missing in most design theories. Maybe the fact is that there is not a 'theory' as it is in database design. Let me explain with an example. Suppose that i want to model different ways to produce orange juice. Let say that i start by a ...
During the meeting, each team member answers three questions: What have you done since yesterday? What are you planning to do today? Any impediments/stumbling blocks? Any impediment/stumbling block identified in this meeting is documented by the Scrum Master and worked towards resolution outside of this meeting. No de...
I am making a .NET desktop application (WinForms+Local PostgreSQL Server) for managing sales in a small store. I wish to integrate Lucene search facilities into the 'Product Search' module of my software. Are there any good patterns for integrating such Information Retrieval Libraries into existing applications? Note :...
My friend gave me a problem that he says is easy, but I can't figure out a good algorithm to use to do it. You are given an input of 100 random English words. You have to find the longest string of words where the last letter in one word matches the first letter in the next word. You can only use each word once. For ...
I am using EF Code First and I had a model like below. public class Account { [Required] public string AccountNo { get; set; } [Required] public decimal Balance { get; set; } } I used a Service class to withdraw and deposit amount to Account. Then I came across this and realised that Account is Anemic....
I am currently working on a project of my own for a little over 2 months (not much time on my hands). The purpose of this project is to be able to remotely update all of my Linux systems from one graphical application. The problem I am having is I am building two applications: the client and the server. As the size of...
I'm using bits of javascript on my website for an image gallery, smooth scrolling, etc. These scripts are not used on every page (not every page has an image gallery for example). However, the scripts aren't very big and most users will have to download them eventually (the image gallery is very central to the website)...
I am currently writing a C code for a doubly linked list(dll) around which I want to write wrapers for implementing stack, queues etc. instead of writing separate codes for all of them. I'll be using void * for making it possible for the doubly linked list to work with any data type. The idea is basically the same as ...
I have an array of points. Each point has two members - x and y. I want to get any 3 points and check, are they located in single line in 2D coordinate system. For example - 1x2, 2x3, 5x6: If yes, I want to search for another point in my array which is located in that line (line has no start and no end). And so on, wh...
I am new to sql. I have added 2 new tables in database. The primary key of first is a foreign key in the other. The type of the keys is integer. Now I want to generate the keys in the code and assign it to new data so that the association between different rows of the tables is right. How do I ensure uniqueness of keys...
I am starting out with C++ and almost everywhere I see there is these 2 sentences at the top. #include <iostream> using namespace std; As I understand namespaces are something to keep names separate and have same identifiers in different namespaces. So isn't including std in the beginning undoing all the hard work of ...
My idea is, to create an abstract class / interface which can be extended into a user, and into a usergroup. There actually is a good reason for there being this interface connecting the groups with the users as the only differences between a user and a group is that you can login as a user and you can't as a group, a...
Imagine a application similar to Facebook, where you have status updates and a news feed. The names and profile pictures can be changed. There are also several different types of updates requiring a different layout template for each type. I hate my implementation and would like some feedback on how to improve it. ...
I have a web application that is accessed by multiple users from different locations worldwide. Let's say I have an "edit" form for a specific document and two (or more) users are editing the document at the same time. I know that both of the users can edit the document and submit it, but user1 will not see that user2 ...
Problem Description I am wanting to use voice recognition as part of a hardware project, which I would like to be completely self containing (I'm using small low power, low speed devices such as Arduino's and Raspberry Pi's, Kinects etc, no running traditional computer with an OS is involved. So a closed / self contain...
I am practicing using of immutable object in C++. My personal goal is representing generic object graph (in heap) with sequence of immutable graphs. Building the multi-version graph itself isn't that much hard. The problem is performance. Brute-force versioning needs full copy of graph, and this was not acceptable. I t...
I often read that developers must write beautiful code, but for a beginner as I am it remains obscure of what is beautiful code and how do you recognize it? The corollary question is: How to write beautiful code and what are some practical habits to improve your code's quality?, what should I care about to make the cod...
I need to execute just few lines of PHP code on every single page of my website. This PHP code does not require more than 4MB memory. That is why i want to allocate just 4MB memory to all pages by using following code : ini_set('memory_limit','4M'); Does it give any benfits in any of the following areas : 1. Website s...
I'm a new guy in this company and I've been tasked to research on possible workarounds with the browser behaviors to cater to the demands of our client. A little background; what they want is to display a 'custom' dialog whenever a user would like to navigate away from a page (not the browser default) that has a form, ...
I am creating a module for a CMS. I found a PHP code in github that does some work for me. The author has not clearly stated the license for the code. Since it is in github and is publicly available, can I use the code in my module or should I get the author's written permission? I am planning to sell my module for a s...
Up until around January 2013, the minor updates of major Java versions were always consecutive: 6u30, 6u31, 6u32, 6u33 and so on. The same is true for Java 7 updates. But, starting around January or February 2013, some minor version numberings were skipped. Take a look here: http://en.wikipedia.org/wiki/Java_version_hi...
I've heard a lot about apple's famous dispatch queues and the GCD but today was the first time I decided to understand exactly what is going on, so I started reading Concurrency Programming Guide and this paragraph caught my eye. If you have two tasks that access the same shared resource but run on different threads,...
I've made a little library called SignalR.EventAggregatorProxy Before I push it into 1.0 state I need to fix so it works safely with concurrent operations. Easiest way is lock all operations but thats a huge performance impact. The library queues event subscriptions and when a event comes in it checks the subscriptions...
One of the Dart criticized features are named and factory constructors. There are opinions (from dependency injection people), that constructors should be simple and just assign some fields and the object graph creation is a responsibility of factories. There are also some argues against the static methods. It seems, ...
I'm not against agile/TDD and use it under most circumstances. However, in some circumstances I feel it doesn't work well. For example, the other day I was building a fairly complex data processing app. In an ideal world I'd layout the foundation, design the components, write unit tests and demo on each sprints as I ...
How would you organise a backlog item that is planned to change in future releases? I've got a requirement that states that: In release 1 users can open content from local machines. In future releases users can open content from remote servers, FTP and web streams. Is it typical to just create 2 backlog items to descri...
A one possible structure for an application is to have it broken down into modules such as Data Access, Core, Services, UI. Now depending on what type of ORM you are using Data Access layer will have a set of entities that represent the tables in the database. The core layer will have a set of entities that represent t...
Bugs happen and sometimes data has to be fixed in production. What is the safest way to go about this from a big company standpoint? Are there tools that can help? Here are some considerations driving this requirement... We need to log who ran the query and what they ran Ideally we need to give the person access to on...
I'm new to a small development company (half a dozen programmers and should grow to possibly a dozen eventually). We also have a few external contractors working with us (just to add a bit of complication). I would like to slowly start adopting Agile, or more importantly short sprints. I was curios to know, from past...
I first came across that algorithm as the "Random minimum cut" algorithm. And recently a colleague was trying to pack a big quantity of small textures into one image file. Then it clicked - why not use Karger for this packing problem? I don't know a good way to map this problem to a graph defined in order to minimize t...
I was creating a new action for a WebApi controller and tried to create a url using the following: @Url.RouteUrl("DefaultApi", new { httproute = "", controller = "ClientApi"}) and noticed that the default route did not have an action attribute, it looks like this: config.Routes.MapHttpRoute( name: "DefaultApi", ...
I need a bit of help to understand the relationship between a viewmodel and a command, and the responsibility of the viewmodel. I'll try to give an example (using Caliburn Micro). I have a viewmodel class, a command class and a view with a Save button. public class EditViewModel : Screen { public bool CanSave {...
I'm currently at the beginning of a build. We are requiring a lot of back end functionality around Clients/Users/Groups/Roles. However, these aren't required for Sprint 1 which is acting as a MVP release. But I want to ensure we are preparing for this enhanced back-end in the future. This is easiest by defining an inte...
My question is related with System.in and System.out classes (there might be others like those in the Standard library). Why is that? Isn't that a bad practice in OOP? Shouldn't it be used like: System.getIn() and System.getOut()? I've always had this question and I hope I can find a good answer here.
I'm working on an algorithm that works best if the inputs are passed to it in a particular order, so I want to sort them that way. The difference is drastic enough for me to consider re-sorting the array. Consider an array a with length n. I want to sort it the following way, and return the array of indices of a instea...
In Java there is a notion of "rich client platform" - it's a framework for building desktop applications, provides common features like help browser, window layout management, etc. Prominent frameworks are Eclipse and Netbeans. Now I am curious if something like that can be done on top of web browser? I heard about XUL...
I'm responsible for creating a presentation to management that details how a system should be refactored or rewritten. We have an existing system that has had production failures and the code base is not in a desirable state. Here are the current possible options: Rewrite the system using developers that provide the b...
I have a class that inflates objects from rows found in a database (or another source, e.g. MongoDB, a CSV file, etc.). To set the object's properties, it does something like self.__dict__.update(**properties) or obj.__dict__.update(**properties). Is this considered Pythonic? Is this a good pattern that I should contin...
I have been going through interview questions and I saw one which made me stop and think for a while. It starts with a quote and asks about your interpretation and whether you agree or not. "For infrastructure technology, C will be hard to displace." - Dennis Ritchie From a bit of background reading you can find that...
The symbols for access modifiers that I know are relevant for many different languages: public:        + private:       - protected:  # package:    ~ (or none) However, in VB.NET there are other such access modifiers -- friend, and protected friend (these are called internal and protected internal in c#). What are ...
I'm trying to log to a file and move it about every 30 seconds. I'm using the os.rename function (which I do from a supervisord process) in python to move the current log to a timestamped log (which will then be processed by another python script) and then I continue to log to the old stream from my uwsgi server. I'...
I have some perl code that uses pack and unpack to transform the data in a way that I don't understand. $unpacked_data = pack('b*', join('', unpack('(b7)*', $packed_data))) Where $packed_data = a Byte Array of say, 2341 bytes, and with the above perl statement, unpacks to 2048 bytes of data. Can someone explain this s...
Binding directly the form to your model helps a lot to get rid of boiler plate code, but that means that your model must have a getter/setter for each property otherwise it wouldn't be possible. Another choice would be to create another layer (DTO) only to carry the data to/from the form and then you can have a rich do...
So with cqrs, we accept that consistency is eventual. However, that doesn't mean that the user has to continually poll, or that eventual means an update has to take more then 500ms to sync. For the sake of UX, we want to at least give the illusion of consistency, or if not possible, be as transparent as possible. Wit...
After reading gnat's answer to Why a static main method in Java and C#, rather than a constructor? I take his answer to mean that the purpose of a Java class with a static main method is to define a program entry point and that it is not meant to be the program itself. There may be a better way to do this, but I usuall...
Recently, we had a discussion about code using protected inheritance in order to hide the fact (to client code) a class inherits from a specific base class but to exploit this fact in the implementation. The following code demonstrates this. It compiles with recent versions of GCC and clang++ (it uses C++11 features): ...
How do you identify users when a programming pair checks in code? I heard a complaint that, often a junior dev will be at the keyboard, using his/her account, but is not going to be the best person to ask questions about the code being checked in (the more senior dev is likely to have the best answer). Is this really a...
I've used a software suite that is installed in offices and on remote vessels. The installations communicate back and forth, and they do that by using a simple proprietary file format that looks something like this: /SHIP:16 MILES=45213 /ORDER:22943 STATUS=OPEN TOTAL=447.84 URGENCY=HIGH /ORDERLINES:22943 ITEM=3544 QU...
I have a hobby project and it looks like there is need to have some API library (which in turn is a wrapper over existing http API) at least for two languages - JavaScript and Python, adding support to Perl would be nice as well. The question is - what are the best practices for minifying the cost of supporting and dev...
I have a software that reads from a file. Each object in the software takes 7 inputs viz. string string string float string float int I have an input file. It contains a number of input values. If input for one object is like: hss cscf "serving cscf" 32.5 ims 112.134 124 (Note: when an object's variable needs multi wor...
I am currently refactoring an application that i built in JavaScript. The application uses a starting hour and a total working hour count in order to construct a timetable for daily, weekly and monthly views. The starting hour and total working hour count are the same for all timetables I considered using a pattern to ...
I have been coding for a while, but mostly scripts and simple applications. I've moved into a new role where it is all about developing Web Apps and using a proper MVC architecture, so I am desperately trying to learn about all that very quickly. I hope this question is not too similar to "Best Practices for MVC Archi...
My problem is with JavaScript in the browser but I guess it could apply to any event-driven environment. I have coded up a widget in my app. The widget allows a user to select an item using 3 different sub-widgets (table, map & gallery). The sub-widgets display the same items and a selection can be made from whichever ...
When downloading various software packages, and executables for Windows, I always see two different types of executables to download. One just says ...32-bit and the other always says ...amd64. I know this has nothing to do with AMD, but it is referring to 64-bit operating systems, so why is this still a norm? Even lar...
I'm currently in the process of writing a support ticket system... Let's say it's a small forum application, or something like Uservoice. Now I want my users to be able to edit their tickets, but still be able to see the old versions of them. Which route should I take in terms of Database-Design? I've thought of someth...
I have a simple console application that will be deployed as a scheduled job. Below is its pseudo code Main(string[] args) { //get xml string from database Reports reports = ReportsDB.GetReport(args[0].ToString()); //Generate xml file using xmwriter //post the file to sftp site } I was wondering how ...
In MVC the Domain Models(from Model Layer) should instantiate other Domain Models or all the Domain Models should be instantiate in the controllers and passed down using Dependency Injections? How do you implement this in real applications? If you choose this path isn't the controller getting to fat?
I have a class that has 3 dependencies. WritabbleDBConnection, ReadOnlyDBConnection and a QueryFilter utility object. I want to do constructor Injection so my class would look something like this. class PersonDataAccessObject { public function __construct($dbWrite, $dbRead, $queryFilter) { // sets to local...
I watched Stuart Sierra's talk "Thinking In Data" and took one of the ideas from it as a design principle in this game I'm making. The difference is he's working in Clojure and I'm working in JavaScript. I see some major differences between our languages in that: Clojure is idiomatically functional programming Most ...