instruction
stringlengths
34
36.1k
I've started in a company that has been developing an app for 4 years. They haven't used any static analysis tool until now so if we include them we will have tons of warnings. Do you know how can we integrate these tools in a way that we get warnings somehow only in new code and we extend their usage to the rest of th...
In Other C++ Features, Reference Arguments of the Google C++ Style Guide, I read that non-const references must not be used. All parameters passed by reference must be labeled const. It is clear that looking at function calls that use references as arguments is absolutely confusing for C programmers, but C and C++ ar...
I find that in the early stages of a project the structure of the data returned by the server can change quite frequently as the data model changes. For example, if I'm building an application that plots the locations of local points of interest I might start by returning json that looks like this : [{"name" : "Odeon"...
I have been building an app for my company i join for the past > 1 year, we're using Java Spring Hibernate Javascript jQuery Kendo UI And for the structure i can say something like this from Backend to Frontend : Backend (pojo > dao > bo > service > web service) > UI ( model, view model, html/view) Well i think ...
I have a number of classes (and interfaces) which 'code to an interface' interface File { ... } interface FileConverter { public function convert(File $file); //coding to an interface public function success($message); public function failure($message); } I feel I can make the FileConverter interface...
I have been working on sorting algorithms for a few weeks now, but one of my question still hasn't an answer: are there optimal sequential comparison sorts for fixed-size – and random-access – collections? Most sorting algorithms adapt to the size of the collection, but knowing the size of the collection to sort allows...
I have a webapi project working in production for few months now. The entire webapi is server to server. There is a need now to have the same functionality in a browser, meaning the customers can invoke via ajax functions directly on the webapi server. Since the webapi is stateless and session usage is not really r...
I read about BEM & OBCSS here and somewhere the author mentioned this: Decoupling selector will not only increase maintainability and scalability: it will speed up the rendering. Most web browsers are caching first-level selectors. .alert and .danger will be cached but not .alert.danger! How in particular are browser...
I have a multi-tenant web application that authenticates against Azure Active Directory and allows users to modify content. What is the appropriate way for me to display the name of the last person who edited an entity? For example, when I ask this question, it will have my user ID tied to it. However, when you read it...
Let's say I want to write an (iPhone) app, which tells you if you are in manhattan or not. This query involves additional computation after a google map API call (and is of course just an example). My question is where would you do this additional computation? On the App itself or on an application server? And in latte...
For SaaS (software as a service), when using a lean or agile development process with short sprints/iterations (e.g. 1 to 3 weeks), which approach produces better quality: deploying/releasing features... during the sprint in which they are developed, or after the sprint (possibly much later if limited alpha/beta relea...
I want to add capabilities for an abstract Model class to send events whenever it updates. To be able to send events, it needs to have access to an EventManager. So, the intent were first, to be able to handle events (e.g. save operation) and second to send Events to the system event handler. My approach is to implemen...
I have a data structure that stores various permission groups for a multiplayer game server. There is an instance of a "Rank" class for each permission group. Each rank also has a name. I need to be able to access all of the ranks both in a Iterable fashion and with a key. There are three main ways I can think of doin...
I am struggling to find a good way to copy over our production MongoDB database to overwrite our development database on demand. db.copyDatabase doesn't work from the command line using mongo-cli. Is there a better way to clone a database and overwrite a current one with Mongo?
Sometimes I'll see some functions use "on" as a prefix, for example, on a button listener: onButtonPressed(); and there are other examples: onStateChanged(); onNotified(); onResume(); Does the prefix "on" have an implied semantic meaning behind it?
I am developing an ASP.NET MVC application, that has a lot of client side interaction ie. a lot of ajax calls to controller actions. Currently I have controllers containing actions (part of the same controller) returning both views and data (json/xml), I am considering is it a good practice to have actions returning da...
I am using getters and setters to for the purpose of encapsulation. public class Student { private String studentID; private String studentName; private String address; public Student(){ //default constructor } public Student(String studentID, String studentName, String address) { ...
My app is running a single instance on AWS EC2 for now and I don't expect it to require scaling till next month. By then I know I'll need to scale to at least one more server if not two. I've read about immutable infrastructure and the philosophy behind it but I've also read the counter-arguments. So, which one should ...
Multiple top-level systems that communicate with each other via messages(events/commands). The Main class of the program wraps around all the systems and has a message dispacher component wich delivers messages from one system to another. Each system contains a lot of objects that need to communicate with each other,...
I have 50 elements n1, n2, n3, ... , n50 and a limited number of buckets, say 5 buckets and each bucket can hold a range from, say 100 to 150 only (which is nothing but the sum of the elements in that bucket), but neither less than 100, nor more than 150. Which algorithm is most suitable for solving this problem, such ...
I'm prototyping behaviour of a new application, and want to write some functions that check on access based on some variable dates. I just want to write separate functions for that, like "canUserSeeThis()" and "canUserSeeThat()" In case one of these returns false, I want to display a message, but I want that message to...
i am not so familiar working with partial Views. The reason behind that is that I really do not have the basics of Jquery/JS/Ajax. But I recently found through some SO post that a partial view can be rendered using AJAX Unobtrusive. The method in the post seems to be really simple using the Ajax Helper methods. But I ...
I am asking here because I feel that this question can be filed under the "algorithm and data structure concepts" category. Background: I have been recently assigned the task to design and develop a new program. Specs are still in the discussion phase and I can have my say, given my experience I will go for either for ...
Realizing that garbage collection and memory management is implemented differently in different environments for sake of simplicity this question will focus on JavaScript (either V8 or Seamonkey). I realize that garbage collection is a means to determine if a portion of memory needs to be deallocated or not. The simple...
I have a lot of duplicate code in my program that basically follows this structure: If condition is true Create ErrorRecord object Call ThrowTerminatingError(error object) End if The structure of this code is exactly the same for each instance, one of two parameters are different. So for example this is part o...
I keep seeing recruiters, developers, etc. refer to Node.js as a framework. In my opinion, this is out of ignorance for what Node.js really is. Oftentimes, in job descriptions, Node.js is grouped in as a library among AngularJS, React, etc. Generally, I see it as being entered by someone that doesn't know the differenc...
If I have a need for simple, private fields, is there any reason I shouldn't just make it a convention to use private, auto-implemented properties instead? For instance, I could do this: private MyClass _foo; or I could do this: private MyClass Foo { get; set; } It seems like the only time I need actual fields is whe...
I am working with the following system: Network Data Feed -> Third Party Nio Library -> My Objects via adapter pattern We recently had an issue where I updated the version of the library I was using, which, among other things, caused timestamps (which the third party library returns as long), to be changed from millis...
In my reasearch of Dependendcy Injection so far I haven't seen an example object being treated as both a client and a service (meaning a service [value, factory, etc] which has its own dependencies). Can a component be both a client and a service without breaking some fundamental aspect of DI? Is this normal to do in D...
I have to create UML documentation for my upcoming project. Now I have previously worked with Java which as an object orientated language is relativly easy to design UML class diagrams for. For my next project I will have to design an AngularJs Application. As some of you might know an Angular application consists of ...
Where I work, we are eight software developers and every task done must be reviewed by another developer. Often, I feel like the code reviews are done too quickly (example: a task completed in five hours gets reviewed in 15 minutes). I know I can easily spend an hour reviewing a task that took five hours to complete. ...
I'm building a complex tree of objects. There are a total of five types, A, B, C, D, and E. There is a single instance of A, which is the root node. A has one or more Bs as children, each B has one or more Cs as children, and so on. The original data format is a stream that consists of 5 numbers (numerical IDs for A, B...
I would like to implement some sort of test environment for ASP.Net projects. I am trying to implement this as an alternative to mocking the entity framework. Here is what I am trying to achieve : Two DBContext classes are used, one for development, one for tests. These two DBContext classes will generate 2 databases...
I am pretty new-ish to unit testing in a more nuanced sense. If have an application function which based on users given input could produce an seeming "limit-less"combination of output, whats the proper way to unit test this and how far might testing go? I am thinking of something like building an XML file which given ...
Currently, I'm implementing MVVM pattern for a WPF application but not 100% no code behind, sometimes I put some business logic code into GUI and so what are potential problems for this? Thanks
As far as I know, there is no way to get a List<T> with the capacity to sort itself. If I add a element, I want the data-structure to insert it in the right position (based on the associated IComparer<T>). I am looking for something with the same logic than SortedSet<T>. I am aware of System.Collections.Generic.SortedL...
I have been profiling a lot of javascript today in writing a firefox js engine bug report, and started really noticing the slight differences between JIT compilations. While there are some obvious things that could cause non-deterministic flagging of "hot" sections of code (for example, inlining or not inlining a func...
(Socket programming newbie here...) So, for learning purposes I've just started developing a chat server and client in Python, and I was wondering how it is usually implemented. When someone connects to the server, does the socket stay alive until the whole client is closed (All messages are sent through it), or is a n...
Some major C projects violate the strict aliasing rules in the C standard and must be compiled with -fno-strict-aliasing. These include Python, OCaml and the Linux kernel. Obviously this is not ideal. However, it seems hard to avoid in many cases, especially language runtime systems where rampant aliasing is the real...
Perl 6 is being released on Christmas Day this year. I'm familiar with Ruby having a history of releases on Christmas Day, going back as far as Ruby 1.0 in 1996 if not further. However, a quick scan of the Wikipedia article on Perl doesn't seem to indicate any previous Christmas Day releases. Did the tradition of new r...
I have found a piece of code online (https://github.com/kenkendk/sharpaescrypt/blob/master/Source/SharpAESCrypt.cs) licensed under GNU LGPL v 2.1 If I would like to make some changes to this file and re-distribute it under the same license (GNU LGPL v 2.1) do I update the copyright date or owner name (in order to refle...
I am developing an application using Angular and REST API and I'm facing a problem concerning user access right. The application runs this way: A user signup The same user creates his organization He invites people to join the organization Every users of the organization are able to manage many different things, like ...
I have a problem I'd like to solve and am not sure whether there is a known algorithm or how the best way to approach it would be. Say for example there is a class of 30 students who are going on a school camp. They will each share a room with other students. Each student can provide a list of 3 friends that they ideal...
Backstory: I am working on a Wizard Setup project and I've ended up with a very big(a lot of lines of code) Form class. Because my form holds a Wizard control which in turn has lots of pages and each page has input controls that need to be taken into account and saved in the database, the events that fire upon user inp...
We are working on a large-ish MVC web application with multiple backing stores including a SQL Server database accessed via Entity Framework 6.0. We are using asynchronous operations wherever we can, but we repeatedly--in initial implementations--come across scenarios where we inadvertently start a second async operati...
I am trying to standardise my code as much as possible, including DocComments, using PHPCS. It seems that the PEAR standards contain two sniffs that require almost exactly the same tags appear in the Class and File DocBlocks: PEAR.Commenting.ClassComment PEAR.Commenting.FileComment Both of these want to see these tags...
Simple question: What is the best/common practice regarding to throwing errors for application configuration providers? Given is a simple key/value-based configuration source: class Configuration string GetValue(key); void SetValue(key, value); Or more extended, with the ability to add/remove key/value element...
In the ISO-8601 there are multiple hour formats, one of them is "kk" for hours 1-24. What is the purpose of this? Are there countries that offset their time? Is it for military usages? The wikipedia article didn't clarify the exact nature between HH and kk. The main source of my concern is the behaviour of the formats...
I am struggling with testing a method that uploads documents to Amazon S3, but I think this question applies to any non-trivial API/external dependecy. I've only come up with three potential solutions but none seem satisfactory: Do run the code, actually upload the document, check with AWS's API that it has been uploa...
If I have a domain class with an instance method Delete(). What is the best way to ensure that any leftover references to an instance that has "deleted itself" are subsequently unusable? This question is very similar to mine, but I think the OP is more broadly concerned with how the API as a whole should be notified o...
We'd like to know what you view as best practices and what has worked for your projects My organization is in the beginning phases of creating a Selenium test suite, and have had some early discussions about how to ensure that our tests are robust. In one of the first tests, we modified the markup under test to facilit...
I'm trying to solve the following problem: A delivery man has N packages to deliver, already sorted. He starts the route at start_time, he works until end_time. I have historical data of his delivery schedules. There's no geographic information between each drop point. How can I predict the delivery times for each pa...
This is a question that lives in my mind from a long time. Does the use of multiple nested conditional statements impact the performance of a taken code? So far I know that programmers have created a precise term to describe this situation, the in-famous "Pyramid of doom" [Wikipedia page], but a side from that how much...
I'm reading about Swift enum's in the Swift Programming Language guide and the text was comparing the differences between Swift's enum and C's enum. This made me curious as to where enumerations came from originally. I did search online before asking and even asked a few people and they assumed C. (I suppose I'm trying...
I am considering a scheme for passing a timestamp value in a cached response, and then sending it back to the service to perform cache invalidation. I'm wondering if that's a valid approach. Is that a common approach? For example, if I have a service that returns a "Foo" record, which is a combination of DB lookups and...
This is all done in Microsoft Access 2007 and SQL Server. We are creating a way for our users to quickly make notes on a customer. These quick-notes will contain tags that will prompt the user for data based on that tag. The tags are to be limited to a few select options for the user to pick from. The tags will be code...
I recently noticed that Rich desktop applications (I define it as an application running inside a virtual machine embded in a web browser, based on tools like Java Web Start, Adobe Flash or Unity web player) seems to become more and more rare. I only see some when I play some plain old flash video games online. They a...
My motivating case is hardware test automation. We have several different testers (benches of lab equipment that connect to the "device under test" (DUT)), and we write test configuration files which instruct the tester what series of tests to perform. The tests performed take in parameters from the configuration as we...
The Law of Demeter states the following: Each unit should have only limited knowledge about other units: only units "closely" related to the current unit. Each unit should only talk to its friends; don't talk to strangers. Only talk to your immediate friends. C# 6.0 introduced a new operator called the null-condition...
I have a database with deep table to table relationships for example Clients (one to many) -> ClientData (one to many) -> ClientJob (one to many) -> ClientProcess (one to many) -> ClientStep... so on. And these aren't one branch trees either. So Clients also has a one to many relationship with another tree of tables. ...
Overview My question revolves around balancing database and code simplicity using 2 options to design around the following requirement. Background Facts The DB: Sql Server The Code: ASP.NET MVC C# using EntityFramework I have a table, AllocationNeed (see below). /****** Object: Table [dbo].[AllocationNeed] Scri...
If I remember correctly, back when iOS 7 was released, there were a couple of issues regarding the public API of certain classes which implementation was completely changed. The following is an example of what I mean: if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { [[UINavigationBar ap...
My team is trying to decide how to best organize/structure our TFS directory. One proposed solution is to create a directory structure that will dictate the namespaces for our c# projects. For instance, if the tfs directory structure for a specific project was TFS\MyApp\Common, then any C# objects in this directory wou...
I am working on a project to anonymize PHI in our health records database when databases are copied to our testing environments. Currently, the database is copied and fields in the tables (first name, last name, address, DOB, etc.) are replaced pseudo-randomly (seed value generated by datetime) with values from a pre-g...
I have a number of angular services (e.g. a user service) which make various HTTP calls and I'm wondering what the best practice would be for handling errors. For example, I could do: function getAll(success, error) { $http.get('/api/users').then(success, error); } Or I could do: function getAll(success) { $h...
I was given an assignment and it is fairly simple, just a special type of search for a special type of objects. However, I was told to implement a set of functional tests and also provide a 1 page test plan. However, I am not sure what this plan has to include. I have searched for samples on-line but they are too large...
I am confused when it comes to the MIT licenses. If I create a project and put it under the MIT licenses and open source it. Can someone just take my project and turn it into something else and sell it? I have read the licenses like 20 times and I'm still confused. Or if I find some code that is under the MIT licen...
Is there a word for the API pattern where a method may get or set, depending on whether it is called with an argument or none? This style is often used in JavaScript: obj.prop(); // Returns value obj.prop(new_value); // Sets new value A variation for dictionary-like properties takes one or two arg...
I work on a software that has a lot of tests. However, instead of helping us develop faster, these tests actually bog us down, because even tiny changes in the application break many tests. Clearly, the tests are too tightly coupled to the application. A big problem is that our application is not designed with testabil...
What I have This is a prototype. I have a pool of 100 clients connected to the server via websockets reporting things and awaiting for commands. The server polls the commands database table of type MEMORY in a loop using a query with WHERE client_id=?. I can insert a combination of client_id+command to that table, and ...
I am reading C# Design Pattern Essentials. I'm currently reading about the iterator pattern. I fully understand how to implement, but I don't understand the importance or see a use case. In the book an example is given where someone needs to get a list of objects. They could have done this by exposing a public property...
::before and ::after are CSS pseudo-elements which allow stylesheet to specify the content. Apart from html usually specifying the content, When do I think of using these pseudo-elements?
Consider following problem : Given: String input with the length n Font(-metrics) - potentially slow in usage Bounds of an abstract Textview which shall contain the text in a specific manner: e.g not breaking any word in the middle but rescaling the lines and/or break the line at another position. The font-size has...
The existing coding standards on a large C# project includes a rule that all type names be fully qualified, forbidding employment of the 'using' directive. So, rather than the familiar: using System.Collections.Generic; .... other stuff .... List<string> myList = new List<string>(); (It's probably no surprise that v...
After spending a great deal of time writing C# and looking at Java, it seems to me that annotations are just an ugly code smell that introduce another conceptual layer that could easily be replaced by existing language features, whether they be keywords (as in the case of C#'s override keyword versus Java's @override a...
I'm building a [Process-Tracker] thing In Excel. I would use Access but I can't guarantee that the End-Users will all have it. So there will be a list of open cases, with a history of the previous steps in the process, the next step to be completed, key information etc. In a nice tabulated layout and sorted by next du...
I've been reading many of the articles and such about magic numbers, i.e. wikipedia article programmers.stackexchange.com article It seemed like no one has considered context as a means of making it acceptable to use a number and not have it considered magic. For example connection.setLoginTimeoutSeconds(30); Vs fi...
For the purposes of providing a concrete example for my question, let's say I'm building an API that provides access to an email system and contains a set of public classes e.g. Mailbox, MailboxFolder, Message, MessageAttachment, and so on. Is it a good idea to try to anticipate how clients may use the API and provide ...
My application has users and administrators. The administrators split into two: super-admin and limited-admin. The super gets all permissions while the limited can be configured to inherit just the admin permissions that are specifically needed. I am thinking to define my permissions the following way. Any user permi...
I have a case similar to this one: Multivariable decisions The difference is, that it's not a single decision I need to make but more like I have a pool of (let's say 10 object) where each object has 4 attributes with 3-4 different states for each. I now need to select the ONE single most relevant of the objects based ...
I have a public REST API for creating new business profile records in my system. The request itself looks similar to this: { "BusinessName" : "AName", "CurrencyCode" : "USD" } You can see the CurrencyCode property on the request is set to "USD" and our REST API documentation incorrectly asserts that we support...
Can I sell a service that is provided using software licensed under GNU GLP? Additionally, this service involves the use and modification of other modules under Apache and other free software licenses. Is the modification and linking of these softwares allowed, even when the licenses are not compatible? Am I under the...
I am working on a web interface that would allow the user to keep track of the amount of time people spend at their establishment. The problem: I don't know what the best way to keep track of this time would be. I have come up with a couple ideas on how this could be accomplished, but none of them are as elegant as...
I designed a basic C# TCP sever that listens on some port. I extended this into 4 other servers that perform very different tasks, but together make up one product. The client needs to connect to each server with the same address, but in this case, 4 ports. Are there any consequences of this, or is this a good design ...
in a simple multi layer architecture, in which layer do I have to implement something like parsing file. For example: I have a file and I have to extract specific information into an object. I think that this stuff is data access, because the business layer need data. How and where the data come from is not the point....
I'm trying to dig deep into C++ and really learn the nuances of the language but one thing I've found to be really confusing is the R-Value reference. The whole double ampersand thing to be clear (in case I'm getting the terminology wrong). It's not a big deal as it doesn't seem to come up often but it seems like it co...
I wonder k must mean something in gitk. Could not find it on Google. Found that git was named by Linus Torvalds out of imagination. But when a tool was added with name gitk, there must be something in their mind. https://www.quora.com/Why-is-Git-called-Git
I work on a large-ish Java project. We are using maven as our build tool, and I use Intellij (14) as my IDE. Currently, if I build the whole project (c. 15 modules) it takes about 3 minutes. Due to the way that we use our code (even in development), I end up doing a full build quite often. On the basis that "what gets ...
I wonder why C++ uses 'call by value' for classes as default? I imagine this could have advantages in the sense of performance (speed). I mean C# and Java pass classes as references as default. What are the reasons why C++ pass classes as copies as default?
I am having a .Net class which has 10 properties like given below: [the datatypes of individual property is just a placeholder here and it can be anything from a primitive type to an object to a list of objects] class MyClass { internal int Property1{Get;Set;} internal string Property2{Get;Set;} internal Mycla...
For a company I used to work for, I had to implement a socket receiver that mostly took data in UDP form over a local connection from some specialized sensor hardware. The data in question was a well-formed UDP packet, but interestingly, the data payload always ended with a CRC16 checksum formed using the rest of the d...
At my place of employment I have noticed a weird thing where developers will include largish libraries to do simple things. To be clear we're a Scala shop. Here are two examples that occured : 1) In one project we do CSV parsing which was originally a 3 line function. Due to the CSV creator not consistently generating ...
I am creating a little stock-management tool for private use. I have different views, which need similar but different filters. As an example I have a "current stock" list where I can filter for supplier, product group and name. I have the same list again but with additional filters for certain boolean flags. I ...
While I subscribe to and usually work in agile workplaces and I believe have reasonable standards, I often find performance problems difficult in the 'heat of battle', and may put off or not get started on as quickly as standard features. Despite building on general performance knowledge for some time, I'd like to know...
Recently when performing a code review I came across something like this: Old Code: WriteLabour(useNewVersion); WritePart(); WriteNonLabour(useNewVersion); New Code: WriteLabour(); WritePart(useNewVersion); WriteNonLabour(); Now let me give you some background. This is very old code, not very object-oriented. Ther...
I am looking at this example Relevant excerpt from above: class AlbumController { public function getAlbumTable() { if (!$this->albumTable) { $sm = $this->getServiceLocator(); //* My Question Lies Here: $this->albumTable = $sm->get('Album\Model\AlbumTable'); ...
I am writing a compiler, for which I devised a rather classic architecture: it's composed of sequential passes piped together, starting with a lexer and a parser, continuing with a macro processor, then a semantic analysis/type checker pass, and finally an intermediate code generator (and maybe IR optimizer that will c...
At work, we have a large internal application which has been under development for close to 2 years now; I've just recently joined the project and some of the architecture has me slightly perplexed, so I'm hoping someone here can provide some advice before I go out to ask the architects these same questions (so I can h...
My company has a fairly large software project (a couple million lines of code spread across many assemblies.) One sticking point we've consistently run into during code reviews has been with the use of shared classes. We have various classes in a shared assembly used for solving common problems that occur throughout...
While storing single character value for the purpose of status, gender, delete_flag etc. which is better data type string or int. Suppose :: status = A/I or status = 1/0 gender = M/F or gender = 1/0 delete_flag = Y/N or delete_flag = 1/0 In such scenarios where string or int can be used, which is better option as per ...