instruction
stringlengths
34
36.1k
When do we use template specializations for in C++, if not for SFINAE or metaprogramming? type_traits, enable_if and others rely on it a lot, but I'm more curious about situations which are more "obvious" uses of templates - type-agnostic algorithms and objects. One can easily create an artificial example of algorithm ...
Introduction to my problem I'm trying to design a very simple video game where there are several Animals players (they all inherit from Animal): Cat Dog Rabbit There are also some performable actions (only one per Animal) they can perform such as: Bite: done only by Dogs (if an animal gets bitten, it will lose an am...
I was assigned a refactoring. We have several modules having similar functions with some differences. My task is to extract common portions of code for DRY principle. I am a little lost how to do it. I could just cut&paste similar fragments of code, extracting them into separate functions, but if I do it this way mecha...
What data structure would be best choice for fast and performant bidirectional SHA-1 to SHA-3 mapping? Or in other words fixed-length string to fixed-length string mapping? To be more precise: There exists a set of data (which might count in mega-objects), over each of which SHA-1 and SHA-3 hash of is taken For given...
I'm a PHP developer, and what do PHP developers do? They create frameworks, so I'm having my way with my little mvc framework project and I've stumbled across a design problem I'd like some opinions on. For my models I've chosen to take the data objects path (if that's the correct terminology), not a big fan of active ...
There is an existing real-time, scientific visualization application that uses OpenCL and OpenGL to render complex 2D graphs. My goal is to incorporate this application into a 3D rendered scene. At the very minimum, the desired application would render a 3D scene with multiple planes that each contain a graph from the...
We have 10 bags. Each bag has 5 compartments numbered from 1 to 5. We have 100 objects to fill all the compartments and bags. Compartment number x in a bag is identical to compartment of the same number in the other bags. Putting some objects together in a bag may be dangerous. The danger ranges from 0 to 3. Putting...
Hi I am in my first year of SE. Learning C. Haskell, html, css, mips, Sql, Software testing and other computer related modules. I have been an organised student before. But I am struggling to find a good strategy to keep up this year. Especially how to write proper revision notes in programming. I find myself forgettin...
I have come up with the following design for my requirement and want know if there is a better way to do it or if you have any feedback on the design. Requirement Assume that an app provides different add-ons and each of these add-ons have a licence. The user is given a license key and he can activate/deactivate the li...
I am trying to write a servlet which does task based on the "action" value passed it to as input. Here is the sample of which public class SampleClass extends HttpServlet { public static void action1() throws Exception{ //Do some actions } public static void action2() throws Exception{ ...
The financial application I am building contains data which is a number that corresponds with two terms. It works like this: number > 0 = overspend number < 0 = underspend Unfortunately the overspend/underspend terms do not have a neutral term, like nospend or whateverspend. Now I'm unsure about how to save this data...
I've done some research and one method used for cross-platform mobile application development is to use the lowest common denominator approach, packaging platform-independent functions in a shared C++ code base, and developing the platform-specific ones in the SDK's native language. I understand the advantages of this ...
I had some ideas, but which one is the best (and why), and is it other way(s) to do this? I thought about : - Sessions - GET Params, but if there is a lot of errors(for example a register form) it could be ugly. - POST Params, but it needs a form with a JS redirection. Objectively what is the best solution?
We have a following scenario where a team A develops a large Visual Studion asp.net MVC project and uses github as a version control tool. In case team A needs an outside help completing a part of this project, how can we achieve so that team B (outsourced) gets access to only a part of a project that is necessary for ...
I have to create a real-time display. On this display I have to get the numbers from an existing business logic component (written in C) and display these Live on a classic ASP-page (legacy app). How can I best structure this solution to reuse the existing c code without refactoring the legacy asp classic website?
I have a class representing the state of my application and I want to create many commands to update this state. class State{ private: list<int> intList; ... } class ICommand { public: virtual ~ICommand(){} virtual void execute(State* state) = 0; } ICommand implementations will spe...
Our team has hired freelancers for creating a website. They did their job well, but now we want to add services for our core product using different server and technologies, but we want user identities to remain the same on the website as well as on the mobile application that will be using these services. Possible so...
In object oriented software engineering, domain- or business objects are those objects dealing with the domain model. What are the other objects called that or not part of the domain model? Helper objects? System objects? Are they sub-divided into different other denominations? What would be examples of each?
I have a class which implements an interface and have responsibility to create item and "maintain" collection of created items. Class have method GetOrCreate(int id) which return instance of created item. public class PoolOfItems : IPoolOfItems { public Item GetOrCreate(int id) { } } Requirements for GetOrCreat...
I am working to implement a Web API solution for development. I have a few C# console apps that run on a server and have their own data access operations, as well as a MVC app running on a similar server. I want to centralize the DAL to a WEB API that can be hosted somewhere. My question is, what is the best way to man...
Let's say you have a validation engine that needs to cover 100 rules to be useful. Let's also assume the team can only deliver about 10 rules per iteration. How would you go about making a "potentially releasable product increment" by the end of the first iteration, when the rules engine would still be missing 90 of th...
I'm making some modifications to an open source project licensed under the GPLv2 (which will of course be released under the GPLv2) but I'm unsure what to do with attribution notices adjacent to the GPL notice at the top of each file. Each file has: Copyright (c) <YEAR> <ORGANIZATION> <GPL> Author: <NAME> <EMAIL> at...
Our organization uses IBM ClearCase to manage its versioning controls (for better or worse). We've been working on our application for several years now, and a large number of activities have started to pile up as 'dependencies' for our existing build work. My understanding from reading the PDF on Dependencies from ...
Upon inspecting Twitter's URL shortening service http://t.co, I noticed that, instead of redirecting to the goal URL using a Location HTTP header and a 3xx HTTP status code, it redirects using the following HTML (formatted for better readability): <head> <meta name="referrer" content="always"> <noscript> <META ...
It seems like a chicken and egg problem. You can make a write function write to some data store, but never know you saved it properly without a tested read function. You can make a read function read from a data store, but how do you put stuff in that data store, to read, without a tested write function? EDIT: I am...
If I have a Solution with a Project with Production code, where do I do the Unit tests? Do I put them in a whole new Solution and reference the Release version of my .dll? I am using Asp.Net Core 1.1, C#. I have a "regular" MVC project, and I have a Core Web API as well I'd like to test. I don't think this question i...
I was wondering which symbol should be used for representing a user event (i.e. button click). seems like it should suffice, but isn't a user click technically ?
For example, a language that I was looking at recently- Terra. You can address the question in the context of any language, I'm just most comfortable with Lua so I'm starting from there. The Terra Language can be metaprogrammed with Lua and is backwards compatible with C. C code can be used inside of it and its code c...
I am getting huge list and it has two fields as follows: Number Designation 10 Principal 10 Teacher 10 Dean 10 Peon Map map = new HashMap<>(); I am using Map to avoid duplicates. {Dean, principal, teacher, peon} are in descending priority and the values can be overwritten. At first, principal...
How can I handle customer specific implementation. So for example a custom needs a different way to show data, a different model or a different logic. I've read about HMVC but I can't find frameworks that support it. Should I handle the problem by creating branches specific for the customer or forking the project? Or i...
In the understanding of GitHub Flow, as seen here, a feature, after code review, is first deployed to production, then merged into master. If there is a second feature branched from the same commit as the first feature, and that too is deployed straight to production, then production will no longer contain the first fe...
public class TaskA implements Runnable { .... } public class TaskB implements Runnable { .... } I have two runnable class as TaskA, TaskB. I want to have a TaskManager to run these two tasks and have possibility to add more task in the future. So I have the TaskManager as following: public class TaskManager { priv...
I have a set of jobs that start by querying an external server for a payload. On receiving the payload, the internal server takes a variable amount of time to complete the job, hence the 'weight'. What I'd like to do is schedule the jobs in such a way that stress on the external server is minimized: if I ran lots of co...
I am confused between choosing Web API or DLL reference for a project I am working on and want to understand recommendations for both the approach. We are having a Web API which exposes an interface for the business logic(BL). We are using HTTP based service and the code is C#. We also have a Web Application which inte...
Our organization codebase is used by various teams. Over the years, the code has evolved and grown without much usage of interfaces. We would like to change that, to reduce chance of breaking changes. i.e. change accessing of common components from Foo foo = new Foo(); to Ifoo foo = SomeFactory.GetFoo(); My question ...
I'm building a system that uses objects that are built using multiple Async queries to a remote server (Firebase) and queries to a local DB. How should I design a module to generate these objects? I was thinking of using a Builder Pattern but almost all of these variables will be received individually from separate D...
We've come across the following case when working on REST API. Users have the ability to expand the product deployment by installing custom JSON configurations. These configurations tend to be lengthy and are generated automatically. We're working on implementing an API call for installing and updating such configurati...
I have a hierarchical data model and am trying to implement their CRUD operations in my Web Application. Currently I have code inheritance for CRUD operations of my entities (resources) as follows: ResourceCommonProcedures as a base class and each Resource procedure inheriting the base class. public class ResourceCommo...
Java programmers are encouraged to store all their configurable parameters in an application.properties file from which they either load properties during runtime or they load during program start and assign them to variables in a config file. The way I used it was to store variable values that I need to tweak betwee...
Let's say I have a Migrator class to run DB migrations. It also has functionality to lock the db and make sure nothing else can run at the same time. I now have another piece of functionality that also needs to lock the db. Should I: just make lockDb() public? split the class into Migrator and Locker? split the class ...
So I want to save different URIs in database. I want format to be forced as well to look up different URIs easily. Is it better to create table like this: CREATE TABLE uris ( id INT(11) UNIQUE PRIMARY KEY AUTO_INCREMENT, scheme VARCHAR(255) NOT NULL, host VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, por...
I'm quite confused about the following terms: Software architecture Software application architecture is the process of defining a structured solution that meets all of the technical and operational requirements, while optimizing common quality attributes such as performance, security, and manageability. It invo...
You've found some code that looks superfluous, and the compiler doesn't notice that. What do you do to be sure (or as close to sure as you can) that deleting this code won't cause regression. Two ideas spring to mind. "Simply" use deduction based on whether or not the code looks like it should execute. However, someti...
My company has been converting to a service oriented architecture, but we have an odd setup. We have a number of web apps. Each one of these web apps currently has their own RESTful microservice. These microservices are essentially an intermediary to our backend REST services. Although they are generally a pass thr...
I've started to implement a full MEAN-stack application (MongoDB, Express, Angular2, node) and I am struggling with the data design for the access management in the MongoDB. In my old thinking tracks, I have a potential relational solution in SQL, but I want to design it with MongoDB, if possible. Here is some mongoose...
Maybe the title isn't that clear so I will explain this a little bit further. I use biojava to perform BLAST searches. However this BLAST.jar contains a lot of classes: org/biojava/bio/program/PdbToXMLConverter org/biojava/bio/program/sax/ClustalWAlignmentSAXParser org/biojava/bio/program/sax/SummaryLineHelperIF org/bi...
Consider you have this 2 simple classes: class Parent { public: virtual void foo() = 0; }; class Child : public Parent { std::vector<Parent*> parents; public: Child() : parents() {} virtual void foo() { std::cout << "Foo" << std::endl; } }; It seems correct to me! But my teacher says since...
I'm working on a project (A development accelerator) which had dependencies with a 3rd party NuGet package for a CMS application. The external NuGet package has some breaking code changes to our application from v1.1 to v1.2. Since our client could choose to user either v1.1 or v1.2 of the CMS application, so we need ...
I use a traditional MVC pattern for my web projects: Controllers: handle use case scenarios steps (can call business logic in models or services) Views: presentation Models...... I hit a wall with the model that prevents me from properly embracing object orientation. I got perhaps the wrong assumption that an entity ...
Because I work at a company with lots and lots of computers, I find it to be a little ironic that it takes half an hour to cut a release of the latest version of our software. The bottleneck seems to be integration tests run by Maven, and the cause of the bottleneck is because those integration tests seem to want to ...
Scenario: I have a production (P) branch and my current (C) branch I created to work on some new features. Some of them are ready, however work on the rest will take more time than anticipated. I would like to push to production (and merge with production (P) branch) features that are ready now, and then continue to wo...
When I declare new classes I like to structure them in a specific style. Each public, protected and private keyword is used to either declare methods or attributes, never both. To further clarify the parts, I use short descriptive comments like in the following example: class SomeRandomName { public: /* methods */ ...
I joined a team which has a different approach to design from mine. I believe in YAGNI approach to design. For example, if a method (interface, class) is unused, it has to be removed. That's it. People in my team are building a modular app, and one of the modules is perceived as "framework". The app is the only user of...
When transferring object through an API, as in schemaless JSON format, what is the ideal way to return non-existent string property? I know that there are different ways of doing this as in examples in the listed links below. Avoid null Return null Remove empty property I'm sure I have used null in the past but don't...
I have a website where users can upload manuals (PDF documents) for their products. Basically, they first add the product to the system and then add 1 or more manuals to that product. A manual can have multiple versions and all versions should be available in the system. In addition, manuals can contain multiple langua...
I have mainly worked on RDBMS databases. Recently studied MongoDB and liked where we don't have to define schemas upfront. So application developers straightaway can start writing the code. Major drawback that is stated in most of the articles is that MongoDB(or any other document based DB) is not good for transactiona...
Which solution for my small problem would you consider a better style? Is there another better option that I am missing? The logic is simple: Process data from a source until you get the END token. I have couple of imperfect ideas: line = read_from_source() while line != "END": process(line) line = read_from_so...
We have a Java application that uses a live 3rd party data feed. There are several steps in our application and in each step the application reaches out to the 3rd party data feed with the current state of the user flow and received back the data for the current step. Recently, we have noticed that there have been prob...
We are a small front-end dev-team working with 18 months of experience and recently we got in touch with a first major project, ie. a medium complexity back-office web app, but with lots and lots of views. Since there are obviously new sets of problems in this project that we encounter each and every day, it would real...
I'm building a large Desktop application, which will have a range of functionality, for each I wish to have a specific class. I'm thinking of using a nested class structure to modularize the code and ensure separation of interface vs implementation: class Manager { public: Manager(); //Initialise *t and *wapi in...
Which are the main advantages and disadvantages of me using opaque pointers for all my structures? I have been thinking about using this approach and here are some trivial thoughts that I have: Trivial advantages: structure implementation is hidden, requiring who uses my modules to use only available implemented functi...
Sorry for the generic question. I have searched all over and found so many threads similar to this, however not one that answers my specific question - perhaps because the term I'm looking for doesn't even exist. A friend of mine is learning programming, JavaScript specifically, and he asked me why this wasn't working:...
When one extends a class, how is the proper way of setting code to be executed upon some event of the base class? Should one handle the base class event this way: Public Class Class2 Inherits Class1 Private Sub MyBase_MyEvent(sender as object, e as eventargs) Handles MyBase.MyEvent ' do stuff here ...
I would like to design a plugin framework, but I have not been able to find an object oriented design that fits my objectives. My broader design goal is for me to let users define classes in a directory. Then, the program would load the classes at run time. The classes would share a common interface such that the prog...
I am teaching myself to code again and thought I would write a card game. I need help with my code design (I am using C#) To start with I am building it as a console application, and later I will extend it so that it works as a web application. The question I have is whether the Player objects are part of the Game obje...
I have been reading a lot lately about some core concepts of JS and inheritance is a bit confusing. Here are the methods that I know of: // Base class function Parent(foo) { if (foo === undefined) { throw new TypeError('foo is undefined'); } this.foo = foo; } // Derived class function Child(foo, bar) { if...
Regarding enums in java how I understood is Sample enum public enum Strategy { STRATEGY_A { @Override void execute(){ System.out.print("Executing strategy A"); } }, STRATEGY_B { @Override void execute(){ System.out.print("Executing strategy B...
From my Operating System textbook, application and library interact with kernel by system calls. But as far as I can see, Windows, OS X and Linux, we can only use C Language to post system calls. That annoyed me when I want to optimize I/O in our Java application -- since I can't use system call directly, So I have to...
TLDR; I'd like to add a (modification) copyright and a MIT License to an Apache 2 licensed file, which I modified. Description I modified a file that was licensed Apache 2. According to what I understand I had to do the following: include the license include the copyright stated the changes that I made I did not inclu...
I've been studying design patterns. I've learned about Repositories, Unit Of Work, Dependency Injection, MVC. I'm now learning about Service Layer pattern. I'm trying to grasp the utility purpose of Unit of Work(if any) in a Service Layer. From my understanding services provide encapsulation for specific model database...
I have nested containers A and B. The attributes are there to show that classes have some other members. One of my functions f takes another container of such containers (let's say vector again). ContainerA{ int a; std::vector<ContainerB> contc; } ContainerB{ int b; std::vector<Element> con...
Most of us know SOLID, and over the years have understood how useful it can get when we need to change. Based on S & I parts of SOLID and from experience I used to design my HTTP RESTful services as fine-grained as I could. For example, in a simple contacts management system, I would create and expose these endpoints: ...
There is a @Mark Seemann's cite from a conversation which states that an abstraction must never implement IDisposable: I like how @nblumhardt put it almost six years ago: an interface [...] generally shouldn't be disposable. There's no way for the one defining an interface to foresee all possible implementations of i...
Recently come across an unusual scenario while normalizing an old relational database. The Facts There's ~8 tables linked to a central table, where references between the numerous tables may or may not exist. There's a lot of data used, and while this table was initially designed, created and mutated over time, perform...
I know this question might be closed as opinion-based, but what I need right now are some opinions supported by arguments. I am building an application with Postgres and Ecto (Elixir) as the persistence-layer. There is an entity that references itself so that you can build a tree-like structure with it. The more I am t...
if (0 == strcmp(val1,val2)) or (strcmp(val1,val2) == 0) vs if(! strcmp(val1,val2)) Any studies or style guides that support one these styles over the other?
So, I am trying to create an English language trie data structure implementation in C++. I have created a Trie and TrieNode class. The TrieNode class takes in its constructor a vector<string> that is a list of words to construct the Trie from. My solution to getting this vector<string> was to use an EnglishWordsListGen...
The CMS we're developing is getting really messy. One of the failing parts is "unit testing". To put it simple: what we call unit testing actually is something rather vague, closer to integration and functional testing, but one of my coworkers (which unofficially is our lead) doesn't care about "sticking to the definit...
I've got a medium-sized project now that's just nearing the end of the "sloppy caffeine-powered prototypes for client demos" phase and transitioning into "think about the future" phase. The project consists of Linux-based devices with software and firmware, and a central administrative web server. 10 prototypes current...
I'm trying to code a kind of simple video game where there are two kind of players: Human Players: They enter an keyboard input CPU Players: A random input is calculated For Human Players there is a T round time and a T' input entering time. Let's say, if T=20 and T'=5, a player has 20 seconds to start typing, but on...
I have to do a task which is reading a text, and create a Class diagram. One of the entities is a Shopping Cart. My doubt is how to represent a Shopping Cart in a class diagram, later on an E/R diagram and implicating an ORM in the process. I've been reading a little bit before asking but I cannot clarify my ideas. Def...
I'm creating my first c++ game engine project (for learning purposes) and in it I've attempted to implement an entity/component system utilizing some data oriented design principles while also not fully giving up my object oriented way of thinking. I have data only component structs: (Example) Position.h struct Positio...
There are only two members in our development team and we started to work on a medium scale web application (Laravel). My question is about testing especially TDD, Do we really start to follow TDD strictly or start development without any test framework and later hire some developers for testing? But if we didn't follo...
There are no keywords in Java that relate to network operations. The "socket" methods such as in OpenJDK dont seem to talk to the network card on the machine anywhere, they simply tell a socket to "connect" to some IP address. At the lowest, primitive level, how does the JVM know when to call the network interface card...
I have recently come across the term REM statement and wondered, is it synonymous with comment?
I need some advice on an approach to log raw request/response data from a few webapps, for all operations and hits on all APIS accessed via HTTP methods (mostly HTTP POSTs), that I have hosted. Objective: capture raw response body at the end of request-response life-cycle. The app is built using Python/Java and nginx i...
In some high level package (which I don't own) I have a Route interface. Now this Route interface contains the detail for a specific rout within my system. The high level package does not contain a method to add get parameters to the route, like /customers?a=b. class CustomerRoute extends BaseRoute implements RouteInt...
Background: We are in the process of converting a traditional multi-service Windows Service (WS) application into an Azure Service Fabric microservices grid running on a Service Bus messaging layer. In the WS application, the "data loader" service was a singleton to prevent duplication of effort with regards to loadin...
I am trying to achieve a round-robin algorithm for sports scheduling that also guarantees a fair or balanced home/away rotation. I based my algorithm on the round-robin scheduling algorithm: def round_robin(teams, rounds): # bye if len(teams) % 2: teams.append(None) schedule = [] for turn in ra...
I was just reading the Wikipedia page for WebAssembly and it says: “WebAssembly is… designed to be faster to parse than JavaScript” , which got me thinking, what makes a certain language or data format faster to parse than others and what parsing algorithms are used?
Been given an awkward design challenge, and I'm not sure how best to handle it. The scenario is this: in the system there's a concept of "Client". Each client has various bits of supporting metadata such as contact name, business sector and so on. The system does two things. It takes bookings against each client, and i...
I'm trying to write a python script that creates 10 threads at a time and runs until I stop it (ie closing the console). I just need it to do basic logging, so when it fails, its just logs a failed result to a log file. The part of the script that I need to thread is just a simple selenium script that goes to a webpage...
I'm using ASP.NET Core's builtin DI container. It's missing some features I need, so I need to use a third-party container. The top ones on Nuget are Autofac and StructureMap. SimpleInjector is consistently the fastest, so I'm considering it too. I have a large code base, so I want to integrate an external container wi...
I am planning to build a version control system to learn some advanced programming concepts in the process. I've used git , perforce and svn. I was wondering if any of them or other uses delta uploads and download like syncing only changes for individual files instead of entire files.
I have this problem: Class1 and Class2 are of same Base type. They are representing the same concept but with slightly different implementation. If I model them "the right way" in Java, I would have it something like this: abstract class Base{ public int id; public abstract void someLogic(); } class Class1 ext...
I have a list of about 15000 items in my database, every one of them has a unique ID and name. New items are added regularly but usually not more than ten a day. My frontend uses a form with autocompletion and this autocompletion is based on the name of the items above. That means that every time someone hits a key, an...
I have to write a software requirements specification for a software system that consists of two front-ends, an Android app as well as a web-application. The Android app and the web-application have similar use cases, but the web application offers more options: Contrary to the Android app for instance the web applicat...
Recently I debated with a colleague of mine about to the following issue: I claimed that it is not MVC sane and good practice to directly load a Model via Zend Framework's ViewHelper because it is a View related stuff and it should call another controller by a hard acceptance. My colleague claims the opposite that a V...
I started development of simulator for simulation of distributed algorithms in language C. My work consist of creating simple language for algorithm description and simulator which takes the described algorithm and simulates it. At first I decided how to represent distributed environment. This simulator will run on sin...
My project can benefit from a bit of code from the Apache commons-math3 project. Specifically, my math heavy application would benefit from using the FastMath class which avoids using extremely precise, but slow, native methods. I have a choice here. I could add an entire maven dependency for this one class (FastMath)...