instruction
stringlengths
34
19.9k
I am currently developing a web application for my thesis.I was asked by my professor to make diagrams to describe the business logic. Since I don't have a prior experience, I am pretty confused with all the terminology. I managed to clarify,I think, what business rules and business logic are, but I can't find out how...
Given 2 strings s1 and s2, if I do a simple equality check , it is considered to be O(n) when calculating algorithm efficiency. So, if I am using a brute force approach for the rotated substring question the efficiency is O(n^2) (take the 2nd substring, rotate by 1 and check. Repeat till rotations = strlen or matched) ...
I am using Android's internal storage to hold data for my application and I am trying to find a good way to handle reading data of an older schema. For example, let's say I have serialized and written several instances of class Data to a file public class Data{ private String text; public Data(text){ th...
I'm a fairly experienced desktop .NET developer with a solid feel for MVVM and WPF, and I've worked with JavaScript, jQuery and HTML/CSS in the past - though I'm pretty dated and haven't had a ton of experience with the new frameworks (Angular, et al). My question is, for anyone who has had to do it, what are the key p...
Closely related to: https://softwareengineering.stackexchange.com/q/45447/48651 I asked a question on SO and it led me to ask this here. If I'm faced with a choice of having a circular reference or just not enforcing the restraint, which is the better choice? In my particular case I have customers and addresses. I want...
Update: Most answers are about how to write a wrapping interface or what is a good wrapper around ADO. but my question is more about when to do so and when not. I never found a good rule for deciding when to write a wrapper and when not. As nobody came up with a suggestion I think the reviewers are right in that this q...
I'm thinking of building a website using mustache.js to render the website and having PHP as the backend. The PHP will then mainly contain queries to the database and some SESSION checkings. Previously I've used plain PHP to render the frontend but it gets way too messy. An example of what I'm thinking: HTML File <ht...
I read about CI/CD, loved it, but I'm having trouble with the details as everything I read was high level. Some authors seemed to suggest that there couldn't be any failing commits on the repository (or master branch?), so a programmer that is delivering bad code would be stopped and he wouldn't be able to create a big...
Say I have this code: if ($this->ship == "e") { $this->price->addLine($this->price->base * $this->price->e, 0, "Export"); $this->price->total += $this->price->base * $this->price->e; } elseif ($this->ship == "d") { $this->price->addLine($this->price->base * $this->pr...
I'm just starting to learn about DDD, and I'm trying to understand how Bounded Contexts can be reconciled with client facing API's like REST/WebServices that use DTO's. For example: your system exposes it's API to the public with a standard WebService, with CRUD style operations for DTO objects with many fields define...
I've been interested in uniqueness types as an alternative to monads in pure functional languages for some time; unfortunately, this is kind of an esoteric area of CS research and online resources about programming with uniqueness types are few and far between. It's obvious how uniqueness types may be used to implement...
I know I have quite frequently heard that C typically has a performance advantage over C++. I didn't really think anything else of it until I realized that MSVC doesn't even seem to support the newest standard of C, but the newest it supports it C99 (as far as I know). I was planning on writing a library with some code...
This is about the third time I've had to write software to control a cellular modem. For those unfamiliar with the process, you have a sequence of steps you have to take. Each step takes a certain amount of time, and there's a few responses you should receive in that amount of time. There are also some responses you...
I've been a C# developer for long time, focused on ASP MVC the most. Two years ago, basiclly due to the lower costs and ease of deployment/management I began to migrate my projects to linux using Node.js for serving HTML and Mono for all the backend operations. They talk to each other using HTTP REST API. As my skills ...
If I use Spring Data Neo4j to develop a software, and I want to publish it for commercial use with charging, does there exist any license issue? I survey many posts about the license issue of Neo4j and Spring Data Neo4j. It seems Neo4j has two versions, community and enterprise, respectively. The Community version is G...
For reference, I am a JavaScript developer learning C++. The browser is a pretty powerful debugger, and I can easily place a breakpoint in my code, hover over a variable or expression and get the value of that expression. Is this even possible in C++ or am I in a different world entirely? I'm starting to write a bit of...
If a Square is a type of Rectangle, than why can't a Square inherit from a Rectangle? Or why is it a bad design? I have heard people say: If you made Square derive from Rectangle, then a Square should be usable anywhere you expect a rectangle What is the problem here? And why would Square be usable anywhere you exp...
Whether or not a value is null could be checked implicitly like this: assertThat(value).isEqualTo("something"); Or it could be checked explicitly: assertThat(value).isNotNull(); assertThat(value).isEqualTo("something"); The latter makes the expectations a bit more clear, but it blows up the test code. Is there a good...
Suppose that there are two class 'A' and 'B' 'A' has a lot of nested conditions that have all unit test covered. 'B' has a property that will call class 'A' and return value according to the result of class 'A' On class 'B', when i want to write unit test. Should i just mock class A and verify on class B that it has be...
I have a table which stores user information, one column stores their ID. I had implemented four different attributes in the same table which stored a bit indicating which file operations that user could perform (read, create, update, delete). Thankfully, I realized that was terrible implementation and instead created ...
I'm modelling part of a software architecture on which several processes run as a workflow. The architecture involves data parallelism, where a certain serial process produces N pieces of data which need to be distributed to N processes that must run in parallel. I'm looking for a good way of expressing parallelism in ...
I'm writing a web service for some physical visualizations of data we are collecting and showing as part of a project we are running locally http://tenisonroad.com/ Some of the visualizations will be screen based and some will be physical (e.g. page 25 of this presentation from Resonate 2014). One thing my web service ...
I work on a Java project with a suggested structure (separate src folders for java files and resource files). After moving the message / text related properties files to that folder, the externalize strings mechanism in Eclipse does not work as before. Usually when hovering over the key string in a getString("") call, ...
I wrote some code about two years ago, which was deployed to the production environment. The code deletes information that is six years old from a system. When it was first deployed there were only 300 records deleted (because only 300 were six years old). Now there are now 10,000 - 10,000 records become six years ol...
This question is about what methodology to follow when evaluating one or more PHP frameworks to see which one would suit the needs of my project best. In other words, given the time pressures that every developer faces, what concrete steps can I take to assess one or more PHP frameworks without having to go to the ext...
I've just written a unit test for this function, which loops through a collection of dates and sets properties equal to true or false depending on whether they're before or after a given comparison date: public void CheckHistory(int months) { var endDate = DateTime.Today.AddMonths(months); Dictionary<Order, boo...
I have been having a discussion with a colleague about the best way to organize a (C#)project after he reorganized a project I had been working on from something that looked like this: To something that looks like this: I tend to sway towards having a few big projects as opposed to many smaller projects, but I am ope...
It feels like it is not enough for working programmers just to "walk" 5 to 8 hours a day, and "quick walk" is not enough, but they have to "sprint", every day, year after year. For the company, it makes a lot of sense because to get the most out of workers, sprinting all day long, day after day is better than people w...
I've written a program to control a bluetooth device. I'm trying to test cases when the bluetooth disconnects, i.e. if its out of range. Physically taking the device out of range is one possibility, but its quite cumbersome and I have to go outside my office to achieve this. What can I do to trigger a disconnection? Is...
I'm having difficulty grasping how to structure/architect a canvas application using an MVC like approach in Javascript. UI will be fairly fluid and animated, the games fairly simplistic but with heavy emphasis on tweening and animation. I get how MVC works in principle but not in practice. I've googled the buggery out...
I have a similar question to this, but not quite the same. I would like for the user of my app to install it with whatever dependencies are needed for the way he would want to use it. So, for example, if they want to persist to MongoDB, then only Mongo-related libraries will be installed, but if they want to persist to...
I am starting with AngularJS. The back end will be Web API (which is new to me as well) and I'd like to use just one IDE, so I'm trying to figure out how to setup a project in Visual Studio 2013 for AngularJS. I'd like to keep it as a separate project, to keep it loosely coupled to the API (or keep the UI decoupled fr...
In the company I work for there is a requirement that all the code should be covered by a test of any kind because they want to have as few user reported defects as possible. With this is mind I decided to put a policy that the code should be unit tested to C0 (100% coverage of each line, not each condition). Now other...
Scenario This was a project that I once had to maintain. After reading Working Effectively with Legacy Code, I started to think how I would refactor this system in a live environment, if I had to (thankfully, I didn't). The system was a legacy system without documentation and extremely tightly coupled. Database relatio...
My understanding is that a Daily Scrum meeting should be very quick, hosted in a friendly way and that it requires all the team members present. Because it is objective is to have everyone up to date with what everybody else is doing. I like Scrum Daily Meetings that are held like that. In my latest project our Daily ...
How must i change the Standard Implemplementation of the Serpent Algorithm that i can use it with the javax.crypto.CipherInputStream or javax.crypto.CipherOutputStream? I must implement/extends the Cipher class and when i do it, what must i change? The Original Implementation of the Serpent Algorithm is here http://www...
I am in a situation where I have a Web Application (WAR) that is accessing a REST service provided by another application. The REST service uses Basic HTTP Authentication. So that means the application calling the REST service needs to store user credentials somehow. To further complicate things, this is an enterprise,...
Often when I design a program with MVC, the controller is useless half of the time. What I mean is this: something happens on the view (e.g. a button click). The view then notifies the controller. The controller then directly delegates to the model and does nothing else because it has nothing to do. For example: User p...
I've just spent hours debugging some code because I forgot (actually never considered it) that TextView.getText() returns CharSequence that may be in fact a mutable class... Shouldn't it return (immutable) String instead? I mean I can't imagine a situation when you want to share a state with a text field, at least not ...
To design in such that it is easy to deploy dependencies with your app, and so that development environments are easy to set up, it is advantageous to isolate an app's dependencies from it's environment. That means the app can get its dependencies from a package manager, and it will not be affected by it's deployment e...
I have been assigned to audit third-party dependencies for one of my company's products to make sure we aren't in danger of running afoul of any licenses. This is probably a job for a lawyer, but such is life when you work at a small company. At my company, we are using CS2J, an open-source project, to translate C# to ...
As I am currently struggling with learning WCF for a project at work, for the past several days I have been looking at online tutorials and examples on the best way to make a WCF client; and today, when I told my boss I was having a hard time finding good tutorials because some of them would not go into details with th...
I have just been working on a new project and doing things the same way I have for years now. However for the first time, I am constantly thinking about scalability and performance of both the application code and the database. So in times past, I have been more than happy to insert a new row, then grab the last_insert...
I don't know what to call this question. This is my example: foreach (var item in lstItem.Where(item => stock.ItemCode == item.ItemCode)) { stock.ItemName = item.ItemName; stock.ItemUnitName = item.ItemUnitName; stock.BrandName = item.BrandName; stock.FamilyName = item.FamilyName; } or // Assume l...
My application generates text files that need to be synced with remote servers, which may be windows or linux. Sync has to happen without user's intervention. I tried with rsync but windows doesn't come with rsync by default. Also it is not possible to supply password in the command line for rsync. Currently I'm going ...
I've got a route that contains objects. Each one has value 0 or 1. I need unique route ID which will identify any objects order. Currently I'm doing it using binary number that is converted to decimal (see picture). The problem is, that amount of objects in route is up to 15. So, decimal number will be very big (up...
I'm developing a application based on two technologies: ASP.net (SharePoint) and JavaScript. I use server-side code for retrieve data from database and manipulate it whereas I use client-side code for build front-end(I'm using JSON format). I have very problem with this "architecture" because ASP.net is strong-type whe...
Are there any industry standards or best practises on how to manage a rapidly changing code base? The types of applications I am developing always have a custom aspect to them. So there will always be some code written which is client specific for every project. The method we are using now is as follows: Several 'CORE...
This is probably a damn fool question, for which I apologise, but I can't seem to get the google syntax right to find an answer. Imagine a Property, like this: private int _type public int Type { get { return _type; } set { _type = value; //raise an event in your chosen language or tech ...
Suppose I have MyClass with a very simple dependency. It uses constructor injection. public class MyClass : IMyClass { private IA A; public MyClass(IA a) { A = a; } } This code get shipped and some other developers are using it. At some point in the future I need to add in a second dependency...
I got into a debate on this question which distilled to if it is a good idea for a specialization of a class to add business rules. Unfortunately this point got trampled in the comments so I'm asking it again as a separate question. I believe two things: An object is responsible for its internal consistency A speciali...
Please consider a program, where the user chooses an algorithm from a list, and the Strategy pattern is utilized to set this algorithm as the model's operation. For example, an image procession application. There are a number of algorithms that can be used to manipulate an image (darken, brighten, contrast, etc). They ...
So I'm a little concerned about my error handling... Currently my execution path looks something like this: Users.aspx -> App_Code/User.cs -> Data Layer/User.cs So now when I try to update a user record, I put my Try/Catch block in the event handler and ensure that only the App_Code class interacts with the data laye...
If you have a menu "Admin tasks" and different admin tasks (like 10) that you could separately assign to each user, but there are users who don't have any admin tasks, how would you deal with "Hiding admin menu" for those users? I was thinking of 3 ways: 1) Javascript, check if Admin menu is empty and then hide it. 2)...
I'm coming from a winforms background and trying to get ahold of MVVM and XAML. Right now I'm wondering how I can take advantage from a data-shaping control (either native or provided by a third party) while maintaining separation of concerns intact. An example: I have a typical third party grid that comes with data gr...
Our team consits of junior and senior developers. Problem I am facing is with the code written by seniors. They are not following MINIMUM coding standards. I am also still learning but I wouldn't declare the inline style or give improper names for variables and controls. I tried to mention it indirectly but they were l...
Note: there is a similar question that addresses my subject: Better style for member variables? ... but that question does not address "dealing with large legacy code base and comprehension of functions that grew too large". I am looking for confirmation or rejection of whether my situation warrants it to be a is a ...
Is boxing of primitives required in OO languages to keep them consistent with the rest of the object system (generics etc.)? Or is it avoidable - is it possible to avoid any additional performance cost of having both primitives and objects in a language? One solution I can come up on the spot is having references big e...
I'm working on a Github repo called Designemplate at https://github.com/benwatkinsart/Designemplate and was thinking of developing some example uses of the CSS file to show how it's used. Should I use a branch called examples and store them there?
I'm creating a website where trust is a big issue, I want to prove by making it open source I actually do what I claim. Question 1. If I make my source code open, how can I prove the actual website runs on this code? But I also have a dilemma, it is a commercial project and I don't want others to run off with it and cl...
Testing code for correctness is important. Whether you do strict TDD or not, tests are really the only way a project can scale in size beyond a point where every team member can reasonably keep all the code knowledge loaded in their brains at once. After that point, tests are imperative in order to ensure future mod...
I'm with an org that is trying to transition to Agile. One thing that I've been struggling with is what they call user stories. In my experience, a user story would be this: Use should be able to accomplish task x using tool y During the sprint, we'd then design a solution to enable this. However, this is what we're...
I wrote a program with Java that plays simple music. Currently chords have only one way ('strumming pattern') to be played. I want to expand this and create different 'strumming patterns' that chords can use to play their notes. The Chord class has a play() method that is responsible for playing the chord. Currently it...
When I've written tests for some code and want to make sure that it's actually testing what it's supposed to, I'll mess up or remove the code-under-test, and see if the tests fail. If they don't, I've got a problem. Is there a name for this technique? It's a real bother having to talk in sentences everytime I want to s...
Category theory has applications in theoretical computer science and obviously is central to abstract mathematics. I have heard that it also has direct practical applications in programming and software development. What type of programming is practical category theory necessary for? What do programmers use category t...
I have an excel sheet which has a large amount of data. I am using php to insert the data into mysql server. I have two problems 1) I have to update a row if the id already exists, else insert the data. 2) BIG PROBLEM : I have more than 40,000 rows and the time out on the sql server which is set by the admin is 60 sec...
What is the best way to track any change made to the SQL Server database before moving to production in case of a large team ? We have used excel sheets but quite often things get missed which come out with SQL compare only during moving changes to production?
At the office we just got a new colleague who is visually impaired. I'm in charge of organizing the planning poker sessions and the new colleague must participate as a member of the team. We have these nice sets of poker cards with planning poker numbers on them, but that doesn't help of course for our new colleague. ...
I am learning about Scrum and currently have a basic knowledge. I have a few questions about the role of the Product Owner in the Scrum process: What is role of Product Owner in daily Scrum, if he/she is part of this meeting? Product Owner is the person who is customer. A team member can be nominated as a proxy of p...
The organisation I work for is very application rich i.e. there are lots of SQL and Oracle databases. We are thinking about a data warehouse. I believe there is a difference between an Enterprise Resource Planning system and a Data Warehouse. An ERP would involve integrating all the systems together and having one da...
Is it generally possible while using source code management to figure out in what version of a file a specific line was added? If so, what SCM systems support this?
I have read the documentation on the apple's developer website which refer following guidelines A view class shouldn't depend on a model class (although this may be unavoidable with some custom views). A view class shouldn't have to depend on a mediating controller class. A model class shouldn't depend on anything ot...
In my project I am dynamically creating table by giving table name (ex. student) and adding fields to that table and then save table. Now, my table is created in SQL Server database. Assume table has data and I want to show the data of table (ex student) on WebGrid. But, the problem is I have no model for that table (...
In the wake of the heartbleed bug, OpenSSL has been rightly critizised for using its own freelist. With plain-old malloc, the bug would have almost certainly been found long ago. However, some kind of malloc wrapping is actually very common. For example when I have a big object that owns many small, fixed sized obje...
My team does 2-week sprints, and the trend we've identified (which we want to move away from) is that our daily standup scrums are relatively straightforward early in the sprint, but then transform into a more frantic scramble toward the end. The first week developers are heads down in coding, analysts are developing t...
Recently I wrote an interpreter for operations on sparse matrices (a "sparse matrix calculator") in lex/yacc. The language is still very bare bones and doesn't even include control structures or parameterized subroutines, yet it is already at several thousand lines of code, and that's not including the matrix classes....
Should you delete the old Nuget package files/folders under the packages directory after you upgrade a package? Maybe I'm just being overly picky, but seeing files/folder for older package versions it bothering me. Is there a good reason NOT to delete the package folders for previous package versions?
The problem is to solve it in n+logn−2 (base 2) no of comparisons. My algorithm is taking some extra space less then (O(n*n)). How can i reduce this extra space without increasing the complexity. comparisionarray=[][] (2D array ) //a function to find the largest. findlargest(a,b) if(len(a)==1 and l...
I am working on a project that now needs business rules. One design discussed is to make API calls (based on the form we are on) which responds with business rules for form input. I am unsure if this is the best way. The business rules are in JSON, but the business rules server actually has a business rules engine (so ...
At my company, we are considering rewriting our business logic and database to have a better architecture after years of organic and unforeseen growth, leading to the inevitable maintenance nightmare. The business model is one where a, let's say, cookie flows through multiple steps, changing states along the way. It is...
So, pretty straight forward question. Somebody told me that all shopping carts should be secure. I can see in some instances where this would be beneficial... but all instances? I realize that typically carts are stored on the server via a session, but in the end the details of the cart have to be sent to the user so t...
I have a java.util.Map<String, Object> object which different types of values in it. I don't want to cast whereever I do a get operation over this. To do this, I created different classes wrapping this map and these classes provide different get methods which return values for different keys. There are two options for ...
In my current code I have felt the desire multuple times to have helper methods that generate a collection of objects and return them as a map of string to object, with the string being some unique id like the objects label. Many of my objects have gaurenteed unique labels since these labels are used via restful inter...
For a project at work, I was tasked to create a WCF service that will receive email messages from client and queue them on a database, while at the same time the service will check the DB every 30 minutes or so to check if there are any new email messages queued, and send them automatically with the appropriate credent...
In Java, there are four available access modifiers for methods: public - any class can use this method. protected - classes in the same package and subclasses in any package can use this method. private - only this class can use this method. no modifier ("package private") - only classes in the same package can use thi...
Whenever I am defining my own events, I use a pattern such as the following (which I believe is how the MSDN recommends doing it): public class MyEventClass { private bool _value; // Backing variable public bool Value { get { return _value; } set { if (value != _value) //...
I have been studying scala for the past week or so and the ideologies associated with it and functional programming in general. As expected, the leap from imperative to functional programming is not as easy as I had hoped. For example, I converted a programming exercise that I did in Java into Scala. What I found was t...
I have recently taken a job finishing the development of a .Net application. The delivery of the application is two years behind schedule. The previous developer died before I had a chance to meet him. I have been given copies of directories from the deceased's laptops. There are many directories of code (including see...
Web applications (.jsp / Java) have the advantage that they can be run from any client browser by putting a single URL into the address bar, and off you go. However, the average web application is slow, clunky, and maintaining the code behind it is hell on earth. Conversely, a typical desktop application (Java / c#) ca...
For SQL and C# app dev jobs, the interviewers usually ask questions about tree,graph and linked list traversals using pure C and pointers. In the 3 years I've spent in my job, I've never had to actually find the path to the 1st node to the right of a given node which is a multiple of the given node for example I ...
I'm a hobbyist programmer working on my own projects. I use Java. Until recently my average project was only 1000 LoC. My latest project however is bigger and is starting to exceed 1500 LoC. I estimate it will reach about 2000. I've never organized my classes into packages. All of them were always in the default packag...
We develop a closed source product and customers want to add two parts: Calendar Contacts Tine 2.0 would provide this, but we want to use it as a library. Since Tine 2.0 uses the AGPL licence, we need to open source our code, if we would use some kind of linking. How can we use Tine 2.0 in our closed source software...
So I think I'm in the right place to ask this question. Its fairly conceptual. I love web development, I work in ASP.NET MVC 3/4/5 C# and have created industry standard applications such as CRM's and Test Case Documenting. I'm very aware of the limited capabilities of Web Application over Desktop Applications. Desktop...
What does the word Representational State Transfer (REST) mean actually ? Now I don seem to find any relation between its naming and its working, I have understood that it is a architectural style for programming web service and I've read all the hush hush stuff but can't find a reason behind its naming. What is Repre...
I should preface this by saying that I'm mostly a front end web developer, trained as a musician, but over the past few years I've been getting more and more into computer science. So one idea I have as a fun toy project to learn about data structures and C programming was to design and implement my own very simple dat...
I have three simple classes. LoginController, UsersCatalog and User. UsersCatalog has an array of User. I have to represent a simple process of login. LoginController has a method login(username, password) that simply calls a method authenticate(username, password) with the same parameters. Now, it's obvious that the ...
I'm in the process of building a .NET MVC website where a requirement is that admin users should be able to lock accounts to not only prevent future log-ins but to also immediately revoke access to the site for a given authenticated user. Locking the account is easy, but is there an established method of preventing acc...
This was more a discussion for what peoples thoughts are these days on how to split a web application. I am used to creating an MVC application with all its views and controllers. I would normally create a full view and pass this back to the browser on a full page request, unless there were specific areas that I did no...
Is there a design pattern or well known algorithm to build a simple map with roads and city blocks? To have an idea of what's my target i describe some of the constraints and the context: a matrix which represents a (rectangular) map few possible city blocks represented as rectangles (eg, 4x3, 5x2, 1x6) few possible r...
I'm hoping to write a spellchecker for search queries in a web application - not unlike Google's "Did you mean?" The algorithm will be loosely based on this: http://catalog.ldc.upenn.edu/LDC2006T13 In short, it generates correction candidates and scores them on how often they appear (along with adjacent words in the se...