instruction
stringlengths
34
36.1k
I am working on adding a feature to a forum where I look for keywords in posts and add links to these keywords. For example, say a user's post includes the phrase "HP Printers". This phrase would be picked up by my regex and then I would link the word to the HP company page. I have this implemented in php so it searche...
In a 2D game, buildings can be upgraded with modules; Those modules can be bought in a shop. The shop is represented by a stereotyped grid of icons, each icon representing a buyable module. When the mouse hovers an icon, the name a description of the associated module appear in a popup. Currently, the modules are model...
I am working on a ReST based service which calls other ReST based services and also deals with Persistence in a database. So a typical call might look like Get some data from the database. Make a call to an external service using a ReSTClient to create a record. Persist the response to the database. Make another ...
This question is about Dynamics CRM but is valid for every system that allows merging entities. Having data related to a contact in multiple external systems, how would you know which contact the data is related to? Using ContactId works until that contact is merged - then the associated data could point to a non-exis...
This is a problem I run into often, and am looking for the best solution. I will have code like this (python): def func(var, opt): if opt: var = var.set_opt(opt) result = var.get_result() if opt: return [r[0] for r in result] # arbitrary else: return result What is a good, gen...
After using SVN for years I'm finally trying to learn Git. The tutorial explains how with Git you commit to your local repo for much of the time. I thought Git was supposed to make continuous integration easier, but if you're committing to a local repo for most of the time, isn't that tantamount to working in isolati...
I have been tasked with developing a java application that includes retrieving one property from a json response from a web server. Normally when I parse json I go with the standard way of creating a pojo model of the json and then using the google gson library to create the object. However this time I feel that it is ...
I'm unclear on how a BLE Beacon and device architecture works. As I understand, there's two "types" of Bluetooth: a classic version which has relatively high battery consumption (I imagine this being the one the user turns on to pair a device, for example), and a Low Energy version (BLE) used for receiving small signal...
I'm learning the java Spring framework. So far, I understood that Spring will make stuff transparent with its configurations so that IoC and Factory are not too complicated to implement... Now I have coded A LOT but I have never thought of organizing my code based on design patterns... My query is that for a basic CRUD...
Like many (most ?) people, we have multiple "common" libraries managing various things (business objects, utilities, external libraries...) for multiple projects (web service, admin/users site, desktop apps...). As it's set up today, each project copies its binaries in an "assemblies" folder one level higher than the p...
When building an Observer pattern, you need to define your events that the are broadcast and observed. Is it better to define an abstract Event class with multiple subclasses for each event, or to define a single enum, where each event is listed in the enum? option 1: public abstract class Event { } public UserInputEv...
I recently ordered a new credit card. I used the price comparison websites to find the best one that met my requirements. I notice that these websites have a lot of validation on the client side. For example please see here: https://www.moneysupermarket.com/credit-cards/search/?goal=CC_ALLCARDS&purpose=AllCards&from=...
So I'm working on a new MVC project and all data access will be through a web service. I want to put the service reference and web service calls in a sort of data layer in a separate class library project. Now my dilemma is since the "entities" (members) will be coming from the web service, the main web project will ne...
I am trying to develop business application with separated backend (persistence, business logic, server side workflows) and frontend (presentation, some business logic) which communicates using REST API/JSON between themselves. This architecture is acknowledged as good one in Is it normal design to completely decouple ...
Note: I am aware of the poor wording of the title but I was unable to come up with a better one. If anyone has a better idea, then please edit the title. I'm trying to recreate a card game but kind of struggling with a problem. Every card in the game has a color (enum) and rank (enum). Some of the cards have some speci...
I have a Python script that lives in my CI pipeline that is responsible for publishing branches and tags, publishing AAR's to our Maven Artifactory, uploading Javadoc, etc. We used to follow a modified version of Git Flow where we would publish off of either a "support/" branch (for Long Term Support of a Minor Product...
Context I am writing a JavaScript library, and I am finding that I don't know what the best way to support object creation. I came up with a list things that I am considering: var obj = Library.newObj('object-type'); var obj = Library.newObj(Library.ObjectType); // Library.ObjectType is an object containing information...
I'm making a game I have a Replay object that represents all the inputs done by a player to finish a level. It looks like that: class Replay { int replayId; int playerId; int levelId; int length; List<Input> inputs; } I want to be able to search and access replays really fast so I'm storing them in...
In English parlance, the term 'event' is used interchangeably to mean either of: a thing which happened at a point in time (strict physics meaning, computer logs etc) a thing which has a known start time and duration (eg a birthday party, municipal event etc) In my domain language I need to distinguish between these ...
So most companies i've been at say they are agile, but really aren't. I understand...it's hard to transition but I was put as the owner of the QA department in a small company and im really trying to get an actual process going. So one thing that HAS worked is actually get a Kanban board system setup for Issue tracking...
I have the task to write the "technical documentation" for a software which I was developing. One reason or another I have never done this before, I do have experience with SRS, but this is something different. I am not sure whether the term technical documentation is the right one in the case (is technical manual bett...
There are solutions in the market such as Spring cloud, Consul etc. which can store and serve env. specific configuration data. But all of these services involve a runtime or boot-time dependency between microservices which consume the configuration and config service itself. Are there any solutions available which ma...
Doctor is end user of this application Doctor opens desktop application on his pc which is not developed by us. We provide interface to desktop application via interop dll's. Desktop application call interface and through it they call our integration exe which includes some services which sits on doctors pc. This inte...
I have several classes that looks like: (some of them have dozens of cases) function __construct($value) { switch ($value){ case "1": $value = Values::One; break; case "2": $value = Values::Two; break; case "3": $value = Values::Thr...
I have two types of objects: M and N, identifiable by a name. Additionally, multiple Ms can be grouped into one or more M-Group (also identifiable by a name), same for Ns. (If it makes your life easier, you can assume that nesting is not allowed, however nesting would be nice.) A Rule consists of multiple Ms and multip...
Background: I'm writing micro controller C code to write an EBML file. EBML is like a binary XML with nested elements, but instead of start and end tags, there is a start ID, length, and then the data. I am writing this into external Flash in a low power application, so I'd like to keep the flash accesses to a minimum....
Background: My company is working with camera systems. In the beginning we built our application around different models/setups of them, which i.e. consisted of different cameras or procedures to acquire and combine the data they acquired. However, we were always limited to having a single active system in our applicat...
Here's the thing: we have a website which has some i18n. Translations are maintained in DB and manually exported into JSON files which are consumed by our SPA one time on load. Now I have the following problem to solve: I want to put those i18n JSON files to some CDN and when someone makes updates in database, I would ...
Suppose I am writing a C++ library that I intend to distribute in binary form, with interfaces from other languages (e.g. Python). The 'easy' approach of just compiling the library and distributing the DLL or Framework does not work well. For it to work you need to compile the library with every supported compiler and ...
Let's say I have the following model: public class Product { public string Id { get; set; } public string Name { get; set; } public string Category { get; set; } public decimal Price { get; set; } } Now, I'd really like to allow people to add to and view my catalog of products. So, I create the...
For ease of use, I will use a build too to automate the various steps required to build my project on a new computer - like installing dependancies and so forth. Once I've got that all automated, how can I test it? I don't have a 2nd machine to try it on. I don't want to mess up my currently-working environment by firs...
Hopefully this question isn't too application-specific; I'm thinking about it with regard to Excel, but I think it applies to any file-based database that includes embedded code. I'm working on an application that removes certain worksheets and code modules from an Excel workbook before it is distributed to a group of ...
The idea of hashes is they get drastically different results for even the smallest change of data. What I am asking for is the opposite of that. An algorithm that will produce proximity hash values for data that is approximately the same. Regardless of where the difference is, to only measure the extent of the differen...
I have a system where lot of messages come and go over network, each message to be sent or received goes through several states, state change occurs based on external events for example if the linked contents of message are downloaded then it changes the state, if its replied then it changes state etc. A message receiv...
I have gone back and forth on this issue several times. On one hand, you could argue, a repository's single responsibility is to manage the persistent state of an entity, and the consuming application is the one that knows whether it will accept a stale value or not in exchange for performance. However, if you are deal...
We are C# shop (and just starting with TFS) with number of different solutions (and there are lot of them) that represent different components, that we deploy on fairly large number of production servers. Currently, component installations are done manually, where developer would go on each server and install/de-instal...
I am developing a javascript (Node.js) desktop program that works with an existing MySQL database. I would like to (eventually) distribute to others with based on SQLite, or MySQL if they need (or possibly some other database). What is a good strategy for writing database agnostic code? I'm baking in switches like the ...
I've got a scenario where I need to compare two JSON files and override one if the values are different. These JSONs also include arrays (i.e. [) My approach is to traverse one JSON to dictionary O(n), and then traverse the second JSON against the dictionary (also O(n)??). There by getting 2O(n) ~ O(n). Am I day dream...
I understand Web API. I understand websites, how they call a web API and all the good stuff. My question is, how do you control the user view in the website consuming the API, based on the API permissions. The goal would be to not have the view in the website if the user is not authorized to preform such action. Not ju...
I asked this at Stack Overflow but seeing as it wasn't so much a programming issue as a theory issue it wasn't well received. I have a program that issues a unique ascending code every time one is requested. All of it is built client side into the console and there are no issues. However I am trying to integrate the p...
I will release a program (not Alpha/Beta/Testing versions). Should I remove the comments in the code? I have some comments that I added to make the code less confusing to me, but since the program will be compiled, and no one should be able to see my code unless they de-compile my program. Should I remove or leave thos...
This is something hat has been rolling in my mind for quite some time now, but I still haven't found a good approach to it. So here's the thing. We have a server application that has quite a few complex use cases which involve a lot of ifs and elses and handling of customer data. I can't go into the exact details here ...
I am a chemical engineer, working in an 'old-world' industry (petroleum refinery). As a computer enthousiast, I have, from the beginning, used code to help me in my daily job. At first, it was VBA macros, increasingly complex. When I figured it was too complicated to solve some issues in VBA, I switched to VB.NET dlls,...
Please see the code below: public IUnitOfWork<PersonEntities> Create(IRepository<PersonDTO> repository) { var context = new PersonEntities(); var unitOfWork = new UnitOfWork(context); repository._dbContext = context; return unitOfWork; } This is part of a...
I know that obviously every language has its own characteristics and implementations, but from a theoretical standing point, viewing OOP as an abstract programming paradigm, does it allows side effects? Does it change the program state? Every object has its own state and an object can change its own state or another ob...
I would have the opinion and good practices in script programming about using print statements to materialize the control flow (I usually use an anchor mark, then the name of the function just entered, and eventually the step number in the control flow). I usually then print crucial variable to check if all is going we...
I'm working on a software project where we have to build three APIs. One for the home banking channel, one for the agency channel and a third for the mobile channel. The agency API is the most complete one as it has all the functionalities .. then a bit smaller Home API and then mobile API. The architects here made a c...
So I understand what an epic is, but since i've never seen "working" agile in the field it's tough to understand "when" things happen in the agile process. To me, I know you gather requirements at the beginning (obviously), but do you FIRST create epics out of these? and then split them up into individual user stories ...
We're trying to write Go in the most possibile idiomatic way, but sometimes we struggle to find which is the best way. For example in our service we're creating/converting a struct from another one: type Foo struct { ID int } type Bar struct { ID int } Is it better to write something like: func convertAtoB(a ...
I read a lot the past few weeks about something that calls the 90% syndrome. Basically, the syndrome describes a project that reaches about 90% completion on schedule, then stalls, finally finishing after about twice the originally projected duration. I found old articles about this problem which describe it and tried ...
When you compile a C source file into an object file, the function names in the object file will be decorated. Each calling convention will have a different decoration. For example, the following __stdcall function: void __stdcall stdcallFunction(int i) { int j = 12345; } Will be decorated like this in the object ...
I've run into several situations where a POJO where whether a field value is meaningful depends on the value of another field. An example, using Lombok (which we try to use to avoid boilerplate): @Data @Builder public class SomePojo { // an enum whose values are DEFAULT_LOCATION, STANDARD_INPUT, FILE private f...
I am new to high-level (Android / Java) application development and I learned of the MVP (Model, View, Presenter) architecture. But it's not clear what the role and design of the Model layer is supposed to be. Most tutorials and blogs about MVP directly discuss and show examples of the View and Presenter layers, but ei...
I'm writing a reminder application where reminders can be shown or not for each day of the week (similar to Google Calendar). So I'd like to store the following in my SQLite database: Monday: True or False Tuesday: True or False etc. for all seven days of the week I could simply store one True/False value for each we...
I am working on a Servlet/JSP project, the website have users and I need to display a user's profile using the notation myDomain.com/Joe instead of myDomain.com/users.jsp?user=Joe. An instance of my case is this current page, the link is displaying myDomain.com/posts/thePost: https://softwareengineering.stackexchange.c...
I'm creating a small social media website, and I'm faced with a dilemma. There are 2 ways I can design my classes and database that I currently know of. Users can make posts on the website by uploading images, videos, and plain text. My initial thought was to make a class for each post type and they inherit from a par...
How to write Readable Comment when we have to deal with IDs? I will explain this with example. +---------------+-----------------+ | permission_id | permission_name | +---------------+-----------------+ | 1 | Add Category | | 2 | Delete Category | | 3 | Add Product | +-------...
When I work on a developer team (3-10 people), I often notice that getting a precise and shared definition of each what each term in code means becomes an issue as the code base grows. After a few monthes, two totally different concepts can use the same name and two same concepts can use synonyms. It hardens a lot the ...
I was reading Akka Persistance documentation and it says that Akka is good for Event Sourcing. Imagine I have a User entity. Each user is defined uniquely with ID and has some properties and some business rules around how they can be altered. Also, some modifications of User properties can have some async side effects,...
In my company, it's common not to do any intermediate build to check how each feature/bugfix branch is merged in dev. There is only daily build, which always elicit a lot of test fails and build errors. I have been told that it's unreasonable to do build for each merge for over 1000 developers. So I searched how CI is ...
I want to release some C++ code under MIT license in GitHub. I would like to include required BOOST libraries in the repository. No commercial use is currently foreseen. I am pretty new to IP issues, sorry if these questions are obvious. Can I freely redistribute BOOST binaries in my GitHub repository? Do I need to in...
This is actual production code, and I think what I have stripped out is truly irrelevant to the question. (If I'm wrong I'm sure I'll be corrected.) This is a request object received by a .NET Web API application. Our application has dozens of them, and they each have a Handle() method. I'm not the most experienced Web...
What is Allison's Algorithm and how does it aid in converting hex digits into ASCII characters? ;algorithm (found online) ADD AL, 90h DAA ADC AL, 40h DAA http://computer-programming-forum.com/46-asm/f85ec43b17441011.htm
I am currently reading and working through "Clean Code: A Handbook of Agile Software Craftsmanship" by Robert C. Martin. The author talks about how a function should do one thing only, and thus be relatively short. Specifically Martin writes: This implies that the blocks within if statements, else statements, while st...
This is a design-based question. I'm not at liberty to discuss the actual case I'm dealing with, but the example I provide is representative to the actual problem. Background Let's say we are creating books that have different endings based how somebody progresses through the book. For simplicity, our system generate...
I've been looking for the ideal coding patterns used to score well in a Cyclomatic Complexity. Of course, code will be subject to change according to what is being developed but regardless the objective of the application there will always be the fundamentals: conditions, returns etc. For an instance, what is consider...
Here the professor said that, Tournament sort needs (n-1) + 2(n-1)logn comparisons. {Where (n-1) for calculating Maximum or say creating Tournament structure and 2(n-1)logn for other elements to sort} Why did the professor leave out the number of comparisons needed to find the Minimum? Because to calculate min elements...
I am working on a large J2EE application. I am not very familiar with front end development, and I am trying to trace through the entire application(not in one shot). I am looking at a test case right now and know how to create the problem (functionally) now I am wondering how to stop the code at this specific spot in ...
I am refactoring a large code base, and noticing the author often uses "my" to prefix object names. For instance, using myThingy to identify an object of type Thingy. Is this generally considered a good or bad naming pattern? After listening to Software Engineering Radio's episode on naming, I am suspect to naming patt...
I have one interface with let's say 2 methods and has 3 different implementations. public interface IFace { public void method1(Param1 param1); public void method2(Param2 param2); } public class A implements IFace { public void method1(Param1 param1){} public void method2(Param2 param2){} } public cla...
My company is rewriting our web application from scratch. It's a large enterprise level application with a complex domain in the finance industry. We are using an ORM (Entity framework) for persistence. In essence, half of our application centers around gathering raw data from the user, storing it, and then the other ...
Javascript has a pattern for creating private functions called JavaScript's Revealing Module Pattern. It hides your functions in a closure that returns an object modified to provide access to the functions you want public. Both languages have the same lack of a private keyword. Sure you can use the leading underscore c...
I recently asked this question: Return domain objects from the repository I have come accross this article: http://enterprisecraftsmanship.com/2015/04/20/types-of-cqrs/. Option 1 and part of option 2 talk about having a Data Transfer Object for queries and domain objects for commands. Say I have a domain object like t...
I'm working on a larger project. I hope I understood DI well and based-on that I'm able to do this: // domain object holding configuration ata var input = new GeneratorInput { Constructions = new List<Construction>(), InitialConfiguration = null, MaximalNumberOfIterations = 10 }; // poor-man's-DI solution ...
What are the techniques for C programs which allow easily inspecting the state of the embedded device, through a communication link? For example, for a microcontroller device which communicates with other devices, an external device might want to perform queries similar to: What is the battery level of this device? Wh...
I've been seeing people combine SDL2 and OpenGL (glfw.h or glut.h) for a while now, I've done some research and found out SDL2 runs on OpenGL. So why does people combine these two? Some people discussed how they use SDL2 for making the window and OpenGL for everything else, but that doesn't make sense since OpenGL can ...
I have a large calculation to do. While I can utilize all cores, I thought is there any reason to leave off 1 core and not to utilize it? (calculation cpu only no IO). Or am i underestimating the OS that it would not know to handle and do proper context switching even if I utilize all cores?
I was reading this article recently: http://enterprisecraftsmanship.com/2016/09/08/domain-services-vs-application-services/ The writer recommends a class like this: public sealed class AtmService // Domain service { public void WithdrawMoney(Atm atm, decimal amount) { if (!atm.CanDispenseMoney(amount)) ...
I intent to release my code under the GPLv3 license. No problem to do this, until I came upon a 3rd party file. Their owners have the following statement in it (and no other statement regarding copyrights/licensing) Copyright (c) B.J. Frey & D. Dueck (2006). This software may be freely used and distributed for non-comm...
In for example web-frontend development, there are two main ways to structure a project: client -js -component_1.js -component_2.js -html -component_1.html -component_2.html -css -component_1.css -component_2.css vs. client -component_1 -component_1.js -component_1.html -component_1.css -compo...
Most domain driven design examples are for explicit domains - Accounting interface, Airline booking systems, and such. Sometimes, your domain is much more abstract than that. In my case, the application is built around a specific domain, but a very important aspect of the application is the ability to pivot to other, v...
Problem So I'm making a video game and I'm facing a design problem. I would like to pass the reference of a class being constructed to a constructor of another object and pass this other new object to the super constructor of the first class. Basically something like this: class B extends A { B() { super(ne...
Do any lifecycle models exist that are iterative without incremental? Is this even possible?
I'm trying to learn the N-Layer architecture and several other things, and I have a C# solution where I have the following layers: Core/Infrastructure (Folder) Core (Project) Service interfaces Domain models Repository interfaces Business Logic Layer (Folder) Services (Project) Different ser...
It seems to me that Java was the computing language that could be used anywhere and JavaScript was the scripting language for the web and things stayed that way for a long while. There are countless articles about how Java is not JavaScript and vice-versa but they are often quite old. JavaScript has started to move tow...
I am learning about c# and I am a little confused about (non-automatic)properties and the local variable that the property uses. When I use properties, I put an underscore for all the private variables that is used by properties. This helps me differentiate between regular private variables and private variables used b...
Long story short, I've inherited a Java piece of code made of methods like this one: @Override public Action decide() { if (equalz(in.a, "LOC")) {//10 if(( //20 equalz(tmp.b, "BA") && notEquals(in.c,"U") && equalz(in.d,"Y") )||( eq...
I have a legacy application that works with DirectShow filters installed in the system, these are essentially treated as COM components and not directly linked or distributed with the application. If these components are pre-installed in the system, then I can use them, if not then this particular function of the appli...
I'm referring to some architectural styles here and under Object Oriented architectural style there are couple of invariants mentioned. Objects are responsible for preserving the integrity (e.g.,some invariant) of the data representation The data representation is hidden from other objects But no clear explanation pr...
By this I mean something like Student, which is modeling a Student table row: class Student { public string lastname; public string firstname; } It doesn't make sense to me to program to an Interface or even inherit from a "regular" class. I really don't see where I have to worry about coupling here, if I am ...
I am currently working at a company that has a small(2) development team for our ASP.NET WebForms project. This was something we picked up from a previous team. The current team is made up of recent university graduates with little to no experience in source control. We have all read the gitflow page and understand it,...
In MVC (I'm using Spring, although it's not relevant to the discussion) I have a following model: public class User { private Long userId; private String username; private String password; private String passwordRepeat; private String email; private boolean rememberLogin; /// ctors, setters ...
Let's play everyone's favorite game, find the Aggregrate Root. Let's use the canonical Customer/Order/OrderLines/Product problem domain. Traditionally, Customer, order, and product are the AR's with OrderLines being entities under the Order. The logic behind this is that you need to identify customers, orders, and p...
It seems there are lots of resources on how to Mock third-party code when that code is simple. A JSONRequest, etc. but when using a third-party library which requires the configuration of a relatively complex object graph – three or more classes for example – resources appear to dry up. For example, say you been given ...
My application does a lot of database inserts, so disk I/O is a big part of the workload. QA does almost all testing on VM's. I'm concerned that tests intended to detect performance regressions won't give valid repeatable results in a VM environment, since other activity on the physical machine will affect the applicat...
In three popular platforms I'm familar with(.NET, java, python) strings are immutable but lists are by default mutable. In all languages there is some functional support(linq, streams, list comprehensions) so it is easy to transform/filter a list to a different list. Strings and lists are quite similar in that both ar...
One company (who I will refer to as Company NNN from here forth), has a REST API. At my company, we use Company NNN's REST API to provide some content to our end users. If I send the request with the User-Agent header field filled in, the REST API returns valid JSON data. If I send the request without the User-Agent he...
I've been doing Swift development for a while now with Firebase, and I find myself making a lot of code like this: Auth.auth().signIn(with: credential) { (user, error) in if let error = error { print("an error occurred while signing in!! \(error)") return } print("user is signed in with fac...
I'm attempting to build a web front-end based on the MVC pattern, as opposed to based on the libraries involved (e.g. React.js). I'm using constructor-based dependency injection and interfaces to de-couple the implementations of each element (of MVC), but this still leaves a circular dependency. Controller depends on ...
I am currently planning a new project. It is a card game. Users can collect cards a play against others. I started thinking about how an architecture could look. I am a .NET fan and will use C# as my language. I also want to use Azure as my backend. I am curious, how you would split client and backend stuff? Would y...