instruction
stringlengths
34
36.1k
I am on a fairly new team that is also new to TDD and Agile/Scrum. Currently we are developing a project that consists of web API and a native iOS and Android application, with a small team of devs working on each one. We were having a discussion about how to solve issues in developing concurrently and all had differin...
Suppose that I have 3 classes; class A, B which inherits from A, and C which also inherits from A. And I have a mixed list of B and C instances contained under a list of A. What is the best way to identify the inherited class when iterating over the list of A? 1) Store a 'type' enum property in the inherited classes a...
Being portable C++ code, our project has an abstraction layer over threads. This layer has unit tests. This includes tests like that Thread::sleep(100) wakes up in 130 ms, that CondVar::notify() wakes up the other thread in 50 ms and similar. Obviously this occasionally fails, especially when the computer is also doing...
I have a page that displays a set of records. The page has filter section to search records. currently the logical operator AND is applied between all the filter conditions. Now the requirement for including the OR operation has arisen. The user suggested to add a dropdown with AND,OR options next to Value dropdown. B...
Imagine a standard shop system were users buy stuff and products are being stored and presented. The platform saves and manages a lot of data. Now there are managers who want to be able to see this data e.g. via excel sheets, but in generic ways, some want to see all users with their names, some without, some want to s...
First is I'm starting to build a standard XML format/structure for our users. The objectives are: XML that can be used for multiple organisations XML that can be used to map external system data to our system data XML structure should be in best practices XML should be adaptable to change The above are the objectives...
I'm a bit trapped in my own design. I have to extend it far beyond initial expectations. I'll first show how things are now and what behaviours I want to add but don't know how. Currently, the following code works fine. Some things may be discussed (like the builders class, which exists for the sake of Single Responsib...
I have a proxy server that talks to a bunch of services and I want to have a way to prove to servers behind the proxy they are actually receiving a request from the proxy server and not from something else. I thought about letting clients register themselves dynamically with a key/secret pair thing and sign requests wi...
Let's say I have IRepository interface implemented by Repository class(uses database context to implement IRepository methods). And IUnitOfWork interface implemented by UnitOfWork class using IRepository. My questions are: 1) Should I unit test Repository on it's own?(have no idea how, because it uses database context...
Description of the environment: I am implementing a (hobbyist) modern engine for (an old) PlayStation 1 video game Graphical data is represented as packets where it can represent either a polygon or a sprite, (and they are transformed differently to end up as pixels on screen) All those differents type of packets (18...
So I have a Google Cloud AppEngine server which has 2 main jobs. Every Day at 00:00, download lots of data (Firebase/Async), process it, and send out notifications via HTTP, interact with GoogleStorage, etc.. Listen to different types of requests and send out Notifications via HTTP when received. So for testing purpo...
I like to know what the advantages to putting the logic in separate classes rather than putting all the logic in the RuleManager class. For example Separate the classes for each responsibility class RuleManager { public function create(string $name) { return (new CreateRuleCommand($name)); } ...
In the Java course I'm currently doing at university, a lot of emphasis is placed on using JML constructs like @require and @ensure clauses in Javadoc comments. I understand that this is implementing the design by contract paradigm and that certain tools exist that are capable of mathematical verification of software u...
I'm working with a team on an ASP.NET MVC C# EF application that needs extensive Help materials. The Help materials will be stored on a helpdesk site (FreshDesk) so they can be accessed as a Knowledge Base and so we don't have to duplicate the Help materials both there and inside the app. In a proof of concept test,...
My team has to take over a project from an external company. They've provided the last state of trunk to us as a zip file and are trying to convince us, to accept this as a complete delivery of their development. I strongly object this, as I consider source code as the following: code = history of single commits + proj...
I work for a company which has developed a test automation solution and willing to release the same under GPL. I need to know where all do the company need to register and what is the overall process?
I am a full stack developer in a very small company. It has a custom built ERP software using PHP 4 (no framework). Currently, it works fine from the business point of view except for some bugs here and there. Presently, about 4-5 people use it. The company's plan is to offer it as a product to clients with some modif...
I am a beginner in ELisp, but have programmed in C++ and a number of other programming languages before. My rule of thumb (and I think it is a common one) that a function should fit on the screen. However, it should preferably be even smaller (20 lines is on the long side). However, I notice that Emacs has functions th...
I'm trying to retrieve some personal data from an application that has completely disappeared from Google Play, and its author has answered none of my emails. (I'm namely trying to retrieve a private key. I make the assumption it is stored in a keystore) The problem is that I cannot succeed to find the files related to...
Up until now, I have been initializing most of my variables as such: const QString foo("bar"); Which from my newfound understanding, is known as direct initialization. (http://en.cppreference.com/w/cpp/language/direct_initialization) I was looking at someone's code, and in a namespace, they were initializing their vari...
I have a login page, where user logs in via his mobile number, He gets an OTP send via backend server, once he enters a One-Time Passcode (OTP), we hit an API like this: https://backend.com/api/login?mobile=9123123123&otp=1234 My question is this good enough from security point of view or should I encrypt both mobile ...
As part of a program I am developing for practice purposes, I've created a namespace Core designed to contain the core code resources for the program to use. This namespace is in a Class Library project. Two of the sub-namespaces in Core are Core.Files and Core.Errors. In Core.Files there is a TxtFile class that is res...
I am working on a project that manages employee payrolls using php (no frameworks). This application consists of clients (with their own databases). Each database consists of the client's employees and their payrolls. The relevant features are: An administrator can process a payslip twice a month for all employees in ...
There seems to be significant amount of deep information on the lesser time complexities: linear, polynomial, logarithmic; But there isn't a good source of deep information on how to easily determine if an algorithm is either exponential or factorial time complexity. Usually resources have information on the time compl...
For a class like this: class Foo { public: virtual int GetA(); virtual int GetB(); }; Where should I declare a non-virtual function GetSumOfAB()? 1 - Make it an instance method? class Foo { public: virtual int GetA(); virtual int GetB(); int GetSumOfAB() { return GetA() + GetB(); }...
I originally posted this on StackOverflow, but got the message that this was the correct forum for such a question. https://stackoverflow.com/questions/44077183/wpf-arrangable-row-of-rectangles. I am in the process of creating a small application which has the task of visualizing sorting algorithms. I am using the MVVM...
if field is blank or in form print "enter again" else if no credit and debit < 1000 print "less amount" else print "accessed" end if end if I'm very confused in calculating the cyclomatic complexity. For the above program, I get the answer as 3, as there are two conditions and V(G)=P+1=2+1=3. But the answer ...
For any successful programming language, making a breaking change to the language is extremely difficult. This is the case even for those changes where the legacy code could be reliably and automatically fixed with a simple tool (effectively, a trivial transpiler from the old version to the new). Among such changes mig...
We are a product based website company. We deal with online sell/purchase of automobiles. We have an already-established product with daily 100k visitors on our website. Current scrum team - six full stack developers and one Tester. Full stack developers deal with C#, JavaScript, SQL. Average experience of developers ...
I need to present the conceptual architecture of my site in a couple of days. It is an extremely simple web-site: it is made using HTML, CSS, JavaScript, XML and XAMPP for PHP, MySQL and Apache Server which resides locally on my laptop. Basically what can you do on the site is reading some news after you login or r...
I am beginning the process of moving my django stack to docker containers. Most examples I have seen put the Dockerfile and docker-compose.yml files in the same repository as the application source code. I have been using ansible for deployment so far, it's served me well, and I intend to keep it while gradually packag...
For example I have a relationship like this: user (0..*) buys product (0..*) Which results in an association class, called sale, which has the userID and productID. Just for the question's sake, imagine this sale class has NO other attributes, except for these IDs. My question is, should I show this sale class in my c...
Posts may be smaller than they appear! Skip the bulleted list. Lemme Just Say... I know that this is going to be largely (entirely...) opinion-based. Everyone has their own approach, and their own best-practices ideology, but I'm hoping to glean some thoughts from those who have worked on successful web-apps previously...
I was reading Memoization with recursion which tells how for a recursively defined function fun we can do memoization by: -- Memoization memoize f = (map f [0 ..] !!) -- Base cases g f 0 = 0 g f 1 = 1 -- Recursive Definition g f n = f (n-1) + f (n-2) -- Memoized Function gMemo = fix (memoize . g) So I think it is some...
The Kano model of customer satisfaction defines different classes of product features. Among them are Must-be qualities: If these are not implemented the customer will not accept the product. Attractive qualities (delighters): Features that the customer often doesn't even expect in the first place but cause excitement...
For example, should I test like this: // it shouldn't even compile since I'm using a static type-checking expect(addTen('string')).toThrowError() when it is already type-checked like this: function addTen(n: number): number { return n + 10; }
I was in my CS class when my instructor presented me the following classes: public class UninstantiableTest { private static Uninstantiable uninstantiable; public static void setUninstantiable(Uninstantiable used) { uninstantiable = used; } public static void main(String[] args) { Uni...
The use case I am trying to solve is, assigning millions of users to their groups/segments. I have thousands of different criteria from which buckets of users are created. E.g. bucket criteria: All married males in NY or LA assign to Bucket/Segment 1; Currently at the end of day, I query users from a TB scale table i...
I'm working on rearchitecting a game engine in which multiple concurrent scripts run in parallel threads, which unfortunately occasionally gives rise to race conditions. I'm trying to set it up so that all the game logic will run in the same thread, and any blocking call will run as async. Rendering needs to absolutel...
I am working on a very large ASP.NET Web Forms project. Our team wants to rewrite this project with ASP.NET MVC and domain driven design. Is it a good idea to combine Web Forms with MVC? With this idea we can develop every page and use newly developed page in current project. Old pages work with Web Forms and new pages...
I'm exploring how I might build a Write Ahead Log. My Use case is for operations like: Log Messages (INFO, DEBUG, etc) File Uploads Where I would write the some information representing the Log Message or a File Upload to the WAL, then attempt flush that message to it's final destination. Effectively what I am after ...
I have an application I am writing on Linux. It is a Java webapp intended to be run on Tomcat. When it initializes, my application will copy some standalone java utility programs to the host filesystem that it will shell out to over the course of its runs. Assume that it is not desireable for me to run these utiliti...
I am creating a board game (such as chess) in Java, where each piece is its own type (like Pawn, Rook etc.). For the GUI part of the application I need an image for each of these pieces. Since doing thinks like rook.image(); violates separation of UI and business logic, I will create a different presenter for each pie...
My question is related to software cost estimation. In Software Engineering, COCOMO I or II, are for investigating cost, effort, deployment of staff and ascertaining an accurate road map of precise time lines of the entire project. COCOMO-II comprises of four sub-models individually addressing the Application Compositi...
My colleague is trying to fetch only needed properties as best practice for avoid unnecessary workload on database side as below. public async Task<IEnumerable<Product>> GetProducts(List<int> ids) { var items = await _context.Products.Where(u => ids.Contains(u.Id)) .Select(u =>...
I read somewhere that it is better to pass an object into the constructor rather than instantiating it in it. So instead of public function __construct() { $this->user = new User(); // more stuff... } I should do public function __construct($user) { $this->user = $user; // more stuff... } But then wha...
I'm currently in a AngularJS/Javascript environment. Currently the application using the polling method (i.e, to retrieve new data from server in a fixed amount of seconds). This is quite taxing and does not retrieve latest result immediately. Assuming the server is using ASMX for webservice functions and if possible,...
I suppose every project that is considered as huge and diversed into a lot of parts (admin side, widgets, API, website with a lot of stuff and management) can finally encounter that it is actually hard to use only one or several entities by some type everywhere. E.g. let's take booking entity in action. We have some ge...
I have a Visual Studio solution with 4 projects, that closely follows the Nop-commerce structure. The following is the structure of my solution. - Core - Data - Services - Web The Web project is an asp.net mvc application. Now I want to add server-side logging to my solution, using log4net. My question is which projec...
I have a php web application that is written with traditional architecture with templating, controllers and ORM models. I also have a nodejs JSON API web service that accepts incoming connections and responds with JSON responses Both Services operate on the same database and provide similar functionality but they diffe...
Just to get any confusion out of the way: I'm starting from the position where I already know what to mock, where and how to do it. I just don't know how to fit the mocking into the TDD process. So let's say I have a my_function() already done and I want to write MyClass() that uses my_function() somewhere. Let's say ...
Given a set of N objects with assigned weights, how would we find the set of K objects that is closest to the average? The average being sum(weights) / N. Also, how could we compute the next set that is 2nd closest to the average, and continue on to the 3rd, 4th, etc.?
SonarQube is a software product which runs various coding style rules and other metrics similar to FxCop or Re-sharper. It defines breaking the style rules as: "MAINTAINABILITY ISSUE This is commonly referred to as technical debt. Issues associated with maintainability are named “code smells” in our products." htt...
Background I am working on a class library in support of a web site. The library combines related APIs from several different vendors, all of which have their own particular nuances and domain objects. As an example, imagine there is a credit card provider that exposes a BankAccount object, a loans provider that expo...
I am designing a .NET tool that is using reflection to report information on methods inside our assemblies. Its completely object oriented and made up of Assembly Objects, Class Objects and Method objects all with my defined information I am retrieving from reflection. An Assembly contains many Classes and a class cont...
I would like to know how I should go about splitting up the work into tasks/stories for developing a web application? I created an in-house organization tool for the company I work at just to make things a bit easier for our day to day operations. It was very rough and ready, I developed it without much planning and ju...
I've seen branching models with a develop and master branch (with features being merged into develop first), where the master branch was always entirely part of the history of develop and would be fast-forwarded after the build runs and all tests pass. And I've seen others where the master branch would contain actual ...
When reviewing code, I normally try to make specific recommendations on how to resolve the issues. But owing to the limited time one can spend for reviewing, this does not always work well. In these cases I find it more efficient if the developer comes up with a solution himself. Today I reviewed some code and found th...
Trying to figure out what is the best practice when session times out so that i can do it right first time around. Assume user logs into a web app and goes to "/events" page, where they stay till token expires after 15 minutes. When it expires and of course notifies the user (e.g. via alert), it would redirect to the l...
I have been working on a project that deals with, let me simplify, Schools and Students. The general requirement is that certain Students could be assigned to certain Schools to work an internship. But the Schools are not only Schools per se, those can be Hospitals, Prisons, Nursing Homes, etc.. Since I'm using an ORM ...
I've got an idea, but I wonder whether somebody else already has named it. I'm writing code to control a machine with actuators, motors, etc., and software will be responsible for preventing collisions between some of its moving parts. It's mostly useful to organize everything as a hierarchy, but collisions are possibl...
I have a use case where I'm asked to read an XML document that is a list of data, break it up into data sub-elements, and transform those sub-elements (in order) into another document format (like a flat file or JSON array). I could solve the problem using a typical synchronous flow, first processing the entire XML d...
I'm reading this excellent series of articles about stream. Can a definition to anti-pattern in the context of java 8 -Stream will be a stream that does not produce a valid result using parrallel and a valid result using sequential calculation? Example from the article: A good pattern: (the stream can be calculated seq...
While trying to debug a weird issue where I knew an exception should have been thrown but was not, I found the following in the Java standard library's java.lang.ClassLoader class: /** * Open for reading, a resource of the specified name from the search path * used to load classes. This method locates the resource t...
If I define an abstract class with abstract members and without any Generalization is a well design in Object Oriented Design?Can I Replace it with an interface?
Short intro: I build an application, using .NET, Entity Framework (EF) as ORM and an SQL Server for persistence. My knowledge of SQL Server goes far beyond simple requests, and I use it to drastically cut on DB operations. Still I prefer to use EF to cut on writing direct SQL when possible. I have an application servic...
In setting up deep linking to android and iOS apps, I've made some use of custom URI schemes, and they work great, especially as a fallback when the mechanism that allows maps from http: fails (as often happens with technology). However, I've noticed one answerer strongly recommend against creating your own url scheme ...
I have a factory that creates products. To do this I need an instance of some other class, that has nothing to do with the actual factory. However all Products should of course use the same instance of it, so I provided that instance to the factory which then passes it to every instance of the Product: public class MyF...
We have legacy code that has unit tests (wohooo :D [is it then still legacy?:D]). The production code is an exe file, another one is a DLL but with only one single entry point exported (for some plugin interface). Then there are separate unit test projects which need to test the exe and the plugin dll. The current appr...
I'm trying to ascertain whether the use of multiple references to the same property is code smell / an anti-pattern, based on the needs of the organisation. As an example, consider: abstract class Person { public string Title { get; set; } public string Forename { get; set; } public string MiddleNames { ge...
I was working in a story and in last minute, I have been asked to hide something from UI and we will used it next release. Should i remove it or comment it Should i remove or comment anything related to this part from code or leave it if it won't effect in anything.
I'm loading a config file. I'm considering the following ways of doing it. Version 1: config = json.load('myconfig.json') config_elm = config.get('some_config_elm') if config_elm is not None: # use config_elm ... vs version 2: config = json.load('myconfig.json') if 'some_config_elm' in config and config['some_conf...
This page advocates composition over inheritance with the following argument (rephrased it in my words): A change in the signature of a method of the superclass (which hasn't been overridden in the subclass) causes additional changes in many places when we use Inheritance. However, when we use Composition, the r...
I believe the existence of this unit test is justified. However, to me, this unit test seems very coupled to the method implementation, though I'm not sure it can be improved upon. class ItemManager { void save(Item item) { if (item.id == null) create(item) else update(item) } } @Test ...
I have some doubts on how to proceed on my project. Two years ago, we started a small project for a industrial quality control (es: dimensional control). Originally the software must ran only in a PC with a printer but, now, it’s runing on six different PC with a DB server. This six application are all different, in so...
I am creating a javascript application that will live in a library and be used on multiple sites. I am looking for it to have the following features and need some guidance on accomplishing these goals: Use an iife to protect the variable scope of my application. use document ready within the iife to ensure dom manipul...
I recently started to dive into CQRS / ES because I might need to apply it at work. It seems very promising in our case, as it would solve a lot of problems. I sketched my rough understanding on how an ES / CQRS app should look like contextualized to a simplified banking use case (withdrawing money). Just to sum up, i...
Say I need to model two use cases: "do something" via a batch file interface and via a web service call (UC1 and UC2). Batch interface will "do something" with each record in the file, while web service "does something" only once. Each UC has different primary actor and slightly different set of input/output data of "d...
I posted a question on SO whether two threads can simultaneously execute a send() and a recv() on the same socket. I was told that while they could, implementing this was an example of a very poor design. My rationale is that packets must be sent every 20ms, so I cannot wait until I receive something before I send anyt...
I am going to create a game that involves decision matrix's like the prisoner's dilemma. Much like the image below, except not necessarily symmetrical, and the values will change with each matrix I generate. I plan to query the data against a decision table to understand what decisions players made depending on the va...
I'm making an application where the front-end can display resources both as themselves or within a modal. Of course, when the server gets a request for a resource in HTML, it's going to include a layout (with a <head>, maybe a header and footer in body, and so on). However, if I want a modal with the resource informati...
There's already a question about How to write good unit tests. Based on the answers provided there, the key properties of a good unit test - Short Readable and conveys intent instantly Independent Fast Repeatable Tests a single piece of behaviour Has a good name Keeping those properties in mind, how would one go abou...
Note: Questions with similar title have been asked before, but please read the full text before claiming that this is a duplicate. Since everybody in OOP uses the terms getter and setter, I would expect they have a well-defined meaning. But what I found are basically two statements that are somewhat contradictory: (A) ...
During the development phase where code can be produced that has been later changed for shifting requirements. Once the project is released and adjustment requirements has slowed we can go back and firm up some of the code that is considerably less than ideal due to the shift of requirements and its adjustments to me...
My company is creating a PDF survey (intended for other companies to complete) and we're trying to make the solution interactive (conditional checklists that become visible based on the status of other selections). However, we're wary of doing anything that a surveyed company's IT department will flag while looking for...
I've been using CMake for years when developing in C++ using Visual Studio. My directory layout has always seen me separate source code directories from build directories. For those who are not convinced of the merits of this approach, there are a few, such as easier versioning (everything that needs to be versioned go...
I have a lot of cases where I need to persist some information into a database and complete a secondary action using third party system. For example I have a trivial case, to save user information and to send an email to the user about this action. How can this be an atomic process ie. how can I be sure that user infor...
I'm developing a software that manages a shop. Anyone can visit the shop as unlogged user (aka visitor). If you want to buy something you have to login first (you become a logged user) and then you can buy). The logger user is child of the unlogged user. How can I describe this situation in a use-case diagram? Here s...
I'm looking for a collection that would suit my scenario: I will be inserting key-value pairs (both integers) of ID and timestamp. The ID must be unique. At some interval I will be checking that collection for "expired" items (as in the timestamp + X < current_timestamp) and will need to both remove the key-value pair...
This question stems from more concrete problem asked here The problem I would like to discuss here seems to be a very common pattern in software engineering. Many applications make use of two-layered architecture - business layer and a UI layer on top of it. I would like to know what is the most clean OOP way of mappin...
I am integrating an ERP with a 3rd party reseller. When we finish processing orders that came from the 3rd party, we send back 2 API calls: Set the status of the order to ReadyToShip whereby we pass shipment information. Set the status of the order to Shipped. I am unsure what the return type of this method should be...
I am a programmer with some experience in building PHP web apps. My latest idea is to build a web app in Laravel which would let driver-users register the route they are going to take when going from one city to another. Each route will be comprised of cities and towns through which the driver will go through/by. Also...
I currently have a single pre-existing Git repo for a client/server solution that contains three subdirectories for 3 sub-projects: /client - An Angular2 SPA application (client-side TypeScript) /dtos - Language-agnostic web-service DTO (data contract) definitions written in T4 /client - T4-generated TypeScript...
I'm new to MVVM, I get the general idea, but there's one thing that I've been having a tough time finding an answer for. Inevitably an application will have a save button in the UI. The UI talks to the View Model, the view model updates the model objects, and then the model saves to whatever persistence medium (DB, F...
For some reason the below design doesn't sit well with me, but I'm unable to come up with an articulate reasoning as to why. I would like your help in forming a case against (or for) it. Say, the design of FooViewModel is as such: // Some Observables Observable_1: bool Observable_2: string; // --- // // The method whe...
When I was starting in OO programming, mostly Symfony and Doctrine ORM, I have been advised at least one time to apply inheritance mapping for a case as follows: For instance, a HR system which deals with job candidates, employees, former employees, part time employees etc.. There would be an entity class User, and sin...
For example, Gitlab indicates that the develop branch is behind master: Example 1 Example 2 One could make a merge request from master to develop, but as there are no code changes it seems impossible to align these branches. The current approach is to remove the develop branch once in a while and to create it again i...
We need to design a database model for an (internal) inventory system with the following criteria: Inventory can hold only 1 type (Item) object. There might be more than a million Item per user. There is absolutely no use case for querying items for multiple users at once. We should be able to query by properties (aga...
I am trying to implement Single Sign On feature(SSO). I have for now three systems that needs this feature. This SSO is relatively new to me, I have done SSO where the domain is same. There browser is no barrier so it works. So with few research i found this good article on auth0.com. https://auth0.com/blog/what-is-an...
In our IT dept we develop multiple systems in parallel, the systems are deployed to different environments, and they talk to each other using SOAP and REST. It's all ASP.NET but we're not in the cloud. I'm trying to find a way of streamlining environments to reduce complexity. Simplified view, let's say there are 3 sys...