instruction
stringlengths
34
36.1k
Summary Our development/support team creates applications for company employees (invoicing, task management and the likes). We have a recurring issue where users misuse the applications they're provided, using workarounds, stepping outside of business process boundaries, leaving data or automated processes in poor sta...
I'm looking through some legacy code and I've come across a case where the developer has 'extended' an existing class with additional members, using inheritance as his weapon of choice. Essentially it reduces to something like this: struct A { int something_old; }; struct B : public A { int something_new; }; ...
Background I am working on improving the backend design for a video game. The game is live and working fine, but we want to improve various things. As a video game studio, we often do events which sometimes need tinkering with whilst the event is live - we would love to be able to do these changes seamlessly without ha...
I have a use case where I have a Bi-Partite Graph. Call one type of nodes "Type A" and the other "Type B." Now when a Type A node gets added, it forms some edges based on a criterion with Type B nodes (usually how many existing edges does the Type B node have?). Type A nodes are being added consistently (say with every...
I am doing some data scraping from websites, its quite a fairly simple task, getting data from some columns, however, those columns can be empty, strings, or numbers inter-mixed in one single column. Now my question is, what is the best strategy to bring that "dirty" data in a consistent way into a table or database sc...
I've been using firebase database and now firestore for a while. I'm prob an intermediate level programmer and still at uni. I'm still a bit unsure re: the best way to handle calls that are occurring async to firebase database and updating the UI. I've previously used delegates to do this but I was wondering whether GC...
I'm learning ASP.NET Core 2, with Entity Framework Core. A real use-case scenario is a small management of a production process. I have some persistent table like customers, orders, machines, etc... but I also have some "live" tables. Example: the current status of the machines. This information is valid only at the pr...
Let's consider I have an std::string instance filled with textual data and an std::set<std::string> instance with keywords. I would like to know whether the text stored inside the std::string contains all keywords from std::set<std::string>. To achieve this I considered two possible implementations: Returning true or f...
Recently, I worked on an Android project with Kotlin. As an architecture, there were immutable data classes and functions (not methods which are members of a class), where the functions generate new immutable data objects from other immutable data objects. And it felt like the scope of unit tests was reduced to those f...
I encountered in a book some explanation how self referential tables in SQLAlchemy (Python) work, as an example, here is the class Employee with a manager_id: class Employee(Base): __tablename__ = 'employees' id = Column(Integer(), primary_key=True) manager_id = Column(Integer(), ForeignKey('employees.id'))...
Hello Software engineers, So I'm a programmer. Not an "engineer". When I do OOP, I mostly create classes and interfaces the way I want. I do not follow any design patterns... BUT now, not only I want to get better but also I need to write a software that won't be maintained by me... I read in this book a method to orga...
I know that the rule in maths for modulus is this: ab mod n =(a mod n ) (b mod n) mod n I have found the following code for computing the modular exponentiation: pow(base,exponent,modulus){ if (exponent==0) return 1; else { newexp=pow((base*base)%modulus,exponent/2,modulus) if (exponent%2 != 0){ return (bas...
Cheers guys, I am quite new to C++, however, I have some years of experience in programming and I am open for challenges :-) Currently, I am designing a "small" scientific program to perform some physical simulations. With respect to the basis of my problem, I will simplify some of the program architecture aspects. I r...
I'm developing an app for the 2nd time but it's the first time i'm using third party libraries in my application. One of the libraries seems to have an MIT license and the other is the android support library. My main question is practical: How shall I include each library's license text into my application? I'd ...
I have a collection that I'm putting elements into based on some sort of input. About 90% of the time, there will be only one element in this collection. There may be more elements, but each element past the first has an exponentially decreasing chance of appearing. So it might have 2 elements 9% of the time, 3 elem...
In order to fix a bug in an application, I modified a method named postLogin by adding a call to an existing method named getShoppingCart. Code protected void postLogin() { getShoppingCart(); } However, I'm not sure what the best way to write a unit test for postLogin is. Approach 1 Use verify from Mockito to ...
When we design the whole system we have few architecture pattern to select from. One of them is the layered architecture pattern, This pattern seems to be generic enough to fit in all other architecture patterns but with different scale. For example if we choose Microservice architecture, each service still need it i...
I work for a finance startup managing the technical stuff. The COO decided to create a new web site using a contract developer and the owner of the company paid for it ($9k). I'm asked to use the new site (Joomla + plenty of custom PHP code), but it appears to be of very low quality and insecure. For example: It doesn...
I want to create a media management tool, for which I try to draw an appropriate UML class diagram. The tool shall hold a collection of different media types (movies, music, etc.) which inherit from a basic medium class. Each medium has different attributes in addition (e.g. interpreter, director,...). I plan to fetch ...
IDLs like Protobuf, flatbuffers, Cap'n Proto or Thrift allow communication over standardised interfaces between otherwise independent projects. Most often, these projects will be developed in separate repositories, and while they all require the files generated from the interface definitions, none of them are the clear...
I have been into web development with both client amd server side code, and have been using JavaScript Ajaxto receive and manipulate for data along with PHP scripts. However, I noticed that websites like Google and Facebook use PHP forms instead of sending ajax requeststo PHP scripts. What I wonder is that what is t...
I am working on a server application that should handle many requests. There is one thread per each request and each request has a Database operation. Creating connection for each request and doing the DB operation will waste time. I/O operations on each thread may cause many context-switches that will waste time too I...
I started out with the following, simple routine: void originalCode(){ boolean status = getStatus(); function2(status); if(status){ return; } function3(); } But then, additional functionality required calling function1 on the status == true path. It was also important to call functi...
I have read about Persistence Ignorance principle, The ebook give some examples of violations of this principle, but I don't understand. Could you please help me to give some explain? Some examples of violations of this principle include: • A required base class • A required interface implementation • Classes responsib...
For example, i have made a software for someone. Regularly, i will update my application sometime for fixing bug reason, adding some function, or remove some function, etc. After that, i will list what i changed so far for my application and added that to my changelog list. First, i will named my application as "Appli...
I am wondering how transactions with web services are achieved. Let's take an online store for example that needs to deal with 3 services: Inventory management SaaS Delivery management Saas Payment gateway The above services expose their services via REST APIs How would one achieve something similar to database trans...
I am evaluating frameworks and I would like to understand Django's architecture better. Coming form a Java background I developed components separately namely front and backend. More concretely for my backend I use Dropwizard and start a HTTP server. For the front end I use a nginx webserver with some forwarding to ...
I'm used to program Desktop applications and old School (without web Services) web pages. Now after reading up on web Services and also wcf I'm unsure about the area of usage for web Services. The Situation is so, that I have a couple hundred Clients in an external Network who try to Access the Server by sending Status...
Given an onion architecture, what are the advantages and disadvantages of throwing exceptions in the business logic (which is in the center of the onion) for invalid parameters provided by the user? The alternative would be error codes. I do have arguments for both approaches, exceptions vs. error codes, however I find...
I apologise in advance if this question seems obvious to some or whether this question should not even be asked. I have done research about the build process and I do understand the purpose of building for Java, C++, and others because of compiling and generating an executable code. I also understand that build isn't ...
I have a legacy system I need to plan a migration for. It's mainly developed in Ingres+4GL (an old Ingres based form system). I have the following information: Data Structures (data base relations and their relationships) All programs accessing the underlying Ingres Data Structure I coded a parser for Ingres and 4GL...
Please see the code below: public class Customer { private readonly IList<Order> _orders = new List<Order>(); public string FirstName { get; set; } public string LastName { get; set; } public string Province { get; set; } public IEnumerable<Order> Orders { get { return...
About methodology Scrum, specifically during the period of Sprint, is it correct to say that: The scope can be clarified and renegotiated between the product owner and the development team during the sprint. Yes or No? Why?
I'm debating whether or not to start using CSS variables. They're wonderful gifts from heaven ... except that Internet Explorer does not support them and never will. According to Net Market Share IE still (and inexplicably) represents about a third of browsers. At what point is it safe to assume that old browsers can ...
We have turnkey software that we release to clients. We set up a set of servers to run the server SaaS portion, and for many clients, we set up terminals that allow agents to place orders for customers. The terminal software is a ClickOnce app that runs on the client terminals. One group of these clients have ever-so-s...
I wonder if there are well accepted/standardized types of diagrams to describe the architecture of a software implementation, for example, a Clean Architecture. By software architecture, I mean a set of defined modules using high-level abstractions without including any libraries, frameworks, or databases. So far, I ha...
I just stumbled upon an article by Lucas Majerowicz titled "Add git-like functionality to your application using Event Sourcing". In it, he describes using Event Sourcing with events stored as nodes in a graph database (he uses Neo4j). In so doing, it becomes trivial to branch the event store from arbitrary events in ...
At work the Team Foundation Server (TFS) admins have created two separate TFS environments. One called Devl01 and the other Prod01. Is there even a remotely legitimate reason for doing this and in what sense? Just to be clear, I can get to the two different environments in this fashion: For 'Development': http://tfs:8...
I am trying to figure what the best practice with loading data from web apis is. Assume you have a model structure as per below: class School { private string name; private List<Classroom> Rooms; } class Classroom { private string Type; private School school; private List<Student> Students; } class Student { private ...
I am playing around the state machine concept trying to better understand the best areas of their application. The formal definition of an FSM contains the following elements: finite non-empty set of allowed states; an initial state; an alphabet ("allowed input symbols"); state-transition function; and a set of final ...
According to Is it wrong to use a boolean parameter to determine behavior?, I know it is bad: public void myFunction(boolean b){ if(b){ }else{ } } and it should have separate function: public void myFunctionTrue(){ } public void myFunctionFalse(){ } However, this implementation only moves the if-else fro...
Constrained by a main loop outside of my control (eg: UI event loop, game loop, etc...), I have a slow (relative to the main loop's expectations) algorithm involving a loop. Thus, I have to restructure the loop to be ___ (what is this term?) so that it can run partially each iteration (not 1:1) of the main loop (ie: sp...
Everyone is quick to point out the "Rule of Zero" in code reviews, peer conversations, and Stack Overflow comments/answers. I am not a believer. I'd like to be. Usually if enough people agree on something enough for it to get its own label and become an idiom, then it is well thought out.... So, let me explain my reaso...
I am currently working on an application with legacy code that was built using proof of concepts (POCs). These POCs became the finished production-ready code, there were no tests, and the classes have become quite large over time (pretty much god objects and there are multiple objects that follow this structure). These...
I'd like to use Youtube as an example: they use IDs in the form of PEckzwggd78. Why don't they use simple integers? Or imgur.com - they also use IDs such as 9b6tMZS for images and galleries. Not sequential integers. Why don't they use integers (particularly sequential ones)? In what cases is it a wise decision to us...
Components common to all ExoPlayer implementations are: A MediaSource that defines the media to be played, loads the media, and from which the loaded media can be read. A MediaSource is injected via ExoPlayer.prepare at the start of playback. Renderers that render individual components of the media. Renderers are ...
Description Its a follow up question of writing use cases. Taking from nouns defined in my user story and requirement I found the following candidates to be classes: User Question Session Attempt/UserAnswer Score Category/Topic Hint I think the following relationship holds between these objects: User (o2m) Session U...
I am developing some kind of web-based RPG. So for my player domain I came up with this. player object is going to have a lot of parameters like class, level, name and so on. As it rather plain object I store it in the relational database like PostgreSQL for example. I have an entity RPlayer for that. Also I wanted to ...
I have created a Gomoku(5 in a row) AI using Alpha-Beta Pruning. It makes move on a not-so-stupid level. First let me describe the grading function of the Alpha-Beta algorithm. When it receives a board as an input, it first finds all repetitions of stones and gives it a score depending on its usefulness as an threat. A...
We have a main MS Sql server. This is the main data source that delivers and receives data to and from backend administration and (in development) mobile software. We need to make a connection to mobile. That is: the mobile application needs to be off- and online available. The data on mobile needs to reflect the state...
I observed a dubious design pattern in some C# code today used in several methods: public void DoSomething(bool safe=true) { if (!safe) DoSomethingDangerous(); else { try { DoSomethingDangerous(); } catch { // Log error & carry on } } } I am...
Consider I have classes as follows: public class User{ private String name; //other code private String getName(){ return name; } } public class ShowUserInfo{ public void show(User user){ System.out.println(user.getName()); } } I'm quite sure I would not have other variations o...
In Robert Sedgewick's Algorithms book there's this exercise: A folder is a list of files and folders. Write a program that takes the name of a folder as a command-line argument and prints out all of the files contained in that folder, with the contents of each folder recursively listed (indented) under that fold...
If something can be generated, then that thing is data, not code. Given that, isn't this whole idea of source code generation a misunderstanding? That is, if there is a code generator for something, then why not make that something a proper function which can receive the required parameters and do the right action that...
Given some legacy module in a ten year old project, where you have seen none of the code and not used the application, how long will it take you to grok 10000 lines of code from that module? The permutations of possible setbacks and or further-complicating conditions is endless, I know. Let the above problem be a fun t...
I am currently designing a software in which I have to use a rest client. I have decided to use a particular library, but am stuck whether I should use it directly or add a custom encapsulation layer. To make myself more clear, suppose i have to make a request from a function named getAuthInfo. Doing it directly func...
I'm working in the context of a (kind of) microservices architecture where services can have multiple instances that can create new documents in the same collection of a Mongo DB. There is a functional requirement that each document gets a unique ID (like e.g. an employee ID or badge number). Preferably newer document...
From my understanding, combinational logic is dependent solely on input, and sequential logic involves state--memory. When explaining a finite state machine (FSM), however, it is said that an FSM has two combinational functions. However, they both seem to involve memory, in that state is one of two inputs to the funct...
public class A { public static void main(String[] args) { boolean[] test = new boolean[1]; System.out.println(test[0]); } } prints false, as specified by the Java spec. However, public class A { public static void main(String[] args) { boolean test; System.out.println(test);...
I have a doubt with semantic versioning. I'm working with semantic version like is shown in semver Imagine this scenario: A stable version, named as 1.1.0 An unstable version, named as 1.1.1-rc1 A bug is discovered in stable version 1.1.0 and you need to fix it asap 1.1.1-rc1 version is deployed in a test enviroment, ...
We have a few different apps X,Y,X from different third parties and we want to pull the data into a central app C, so when users enter data into C they can pre-populate forms with related data. If they enter a customer-id from app X into C, they will get related customer-id info, address, etc. from X, populating forms...
I am struggling to find a good architecture for what must be a common problem Enable/Disable a button in a View that contains a datagrid, and has validation requirements on the cell, row and collection levels. And to perform this cleanly in a MVVM architecture. If it wasn't for the datagrid then this would be eas...
As an exercise, I recently implemented a simple settings reader class which reads setting values from an INI file into an std::map<std::string, std::string>. The reader method looks like the following: std::map<std::string, std::string> readSettings() { std::map<std::string, std::string> settings; for(std::str...
I'm writing a program in Java where at one point I need to load a password for my keystore. Just for fun, I tried to keep my password in Java as short as possible by doing this: //Some code .... KeyManagerFactory keyManager = KeyManagerFactory.getInstance("SunX509"); Keystore keyStore = KeyStore.getInstance("JKS"); {...
Overview This is a follow up to my previous question that was flagged as a duplicate, and I do not know what would work better as the title. Here is a link to the previous question: Legacy code: what to do in regards to maintenance and moving forward? And the link to the proposed duplicate: What is the most effective w...
We are working on the design for an appointments system which has to work at remote locations, comms via 4G. Unfortunately a connection to the server may not be available at all remote locations, so data must be pre-downloaded before departure to the off site location, just in case. The UI should be presented on mobile...
I have an "easy" question, but since I am not a very experienced programmer I would like to hear what some of you have to say. If I have for example a Db called MyDb with many tables. Two of them are Company and Address. The relation between them is that a company can have a lot of addresses (each for one office or sth...
My question is similar to this one: Storing data in code Please see the code below: public class EnglishCurrency { public override System.Collections.Generic.IEnumerable<decimal> Values() { yield return 0.01M; yield return 0.02M; yield return 0.05M; yield return 0.1M...
How to save a website of 10 pages in one piece to view it offline (but with CSS and JS in place)? I tried to save a webpage to view offline from the browser via Firefox: File > Save page as > Webpage (complete), HTML. The webpage is saved in a folder containing its HTML, and CSS and JS files but it appears messy, not ...
Guys, I am a non-technical founder with some understanding of how the web app works front end and backend, etc. I have a somewhat technical question to help me make a business decision. I hope you guys can help me. I have two different apps built on two different platforms, Express web framework and another one in ROR...
In my app, I'm implementing a questionnaire system and I'd like to implement tags for questions -- very similar to tags in questions here or Stack Overflow. I wanted to get some advices on how to implement this as a property in my object. Should they be an array of strings -- as below? { "id": 123, "question": "Wha...
I have a large number of expressions which I am trying to solve. List 1 contains formulas like A = B + C. List 2 contains additional equations for those variables, like C = D*3, C = B/2, B = D*50, etc. List 3 contains values for those variables B, D, etc. I then need to compute all possible results for the List 1 for...
I'm trying to improve the performance, code quality and just make it better in terms of practice overall. I have a server for a game that managers all users connected as well as things like objects and rooms + a lot more. Its divided by rooms, each room will have players and objects placed. During the execution of this...
A bone-bare example of decorator is: def strong(func): def wrapper(): return '<strong>' + func() + '</strong>' return wrapper @strong def greet(): return 'Hello!' wrapper is an entitled name for the 'inside first-order-function' inside the Higher-Order function strong. My question is that the word ...
I would like to know what strategies do you use to deal with A/B tests of your app and gitflow. Overview: We are a team of 6 programmers who develop and maintain a large App. So far we have worked on gitflow with a few add-ons on the process added by us which worked perfectly well for a couple years. In a simplified wa...
TL;DR How is the new .NET approach to being a multi platform framework better than what Java did long ago? What are the key differences in the implementation? What are the advantages and disadvantages of each? You can nowadays compile and run C# code "natively" in Linux and Mac. All of this because .NET is going mul...
We have a story "Scale service to X 000 transactions per second". It's unclear how to do that and how much time will it take. Usually in this case you can define a Spike to find out what obstacles you will face during implementation, what steps have to be done etc., so on the next Sprint planning you have enough inform...
My system will deal with Google map API to locate user's location after his/her request. I am drawing the use case diagram and wondering if "Google Map API" should be an external actor to my system or not.
Say I have a entity that has "type" attribute. There could be 20+ possible types. Now I'm asked to implement something that would allow changing the type from A->B, which is the only use case. So should I implement something that allows arbitrary changes of type as long as they are valid types? Or should I ONLY allow...
So I am learning reactive programming, and I am building an app for fun that listens on various stock information tickers, and calculates specific things to show in charts etc. So right now I have information coming from different sources, each of one is one RxJS observable (think stream), so my "ticker$" observable is...
Let's assume that we have a service that needs to be initialized, but then it's a singleton. For example, something like this: public interface IGraphsContainer { void Initialize(IEnumerable<Graph> initialContent); void Add(Graph graph); bool Contains(Graph graph); IEnumerable<Graph> FindAll(Criteria...
I was mildly surprised to find this function in our code base: public static double ToDouble( object value ) { if ( value is double ) { return (double)value; } else if ( value is decimal ) { return decimal.ToDouble( (decimal)value ); } else { return double.Parse( value...
Overview I work in a company where we moved to microservice architecture recently and we are constantly growing our services each day, but I found that we have problem maintaining and monitoring all these configuration files spread across the servers and cloud environments. So I thought myself why not start open sourc...
Background: So while Javascript implicitly convert various data types and hence may seem almost type-less(is there such a thing?) it does have different types. Most of my colleagues seem to think otherwise. The pre-sales and non development colleagues are unaware of this and other developers(90% are senior to me) seem ...
Why there is common coding convention in PHP. Just like python has pep8 .Some frameworks prefers camelcase but wordpress uses underscore while naming functions and variables which is actually preferred.
I am beginning a project and I was wondering If I can use CQRS and Hexagonal architecture in the same project, or in fact they are incompatible. I read about CQRS and some people agree that it is not an architecture, and more like a pattern. What do you think?
Say I am developing a Calculator application. It has one class called: Calculator. Therefore my namespace structure would look like this: MyCompany.Calculator.Core.Calculator Unfortunately, this is not right because the same name should not be used for a namespace and a type in it. This is thoroughly explained in t...
I have system requirements that the system will send an alert to the user. This requirement is the most important requirement of my system. Is it represented in the use case diagram or not? Thank you.
I am trying to understand better MVP Architecture on Android.To do that, i want to implement MVP on android project from beginning. First i tried to use one module, which is app(Application app),but my app started to grow a little fast than i expected.And testing takes way to much time to finish or i they give me an ...
Does a programming language team have any tool to validate their new ideas about new code syntax? As an example, let's assume the Java language team starts developing new feature, which requires new syntax. This feature is supposedly new public keyword, that is allowed to point which classes will see this class. One de...
I'm designing an web app with React as front-end, and I'm trying to properly understand REST API practices. Reading resources online, one can get the idea that the REST API is seen kind of like an adapter to the database. However, what with "relative" resources? For example the ones related to the current user or the c...
Edit: Assume that I will stay on this project until "the end". The Problem I'm currently working on a legacy interesting Java project(s).  A full rewrite is currently out of the question, as I am working alone, and the current desired functionality was due months ago (before I came onto the project).    It is rather l...
We recently started migrating a ton of small apps from our legacy Lotus Notes system to SharePoint and other internal web applications. In doing so, our developers have been spinning up lots and lots of repositories in our Visual Studio Team Services (VSTS) work space, many of which are single-use migration application...
While working on an inherited project, I noticed the original dev(s) created many asynchronous functions that never seem to take advantage of being, well, asynchronous. For example: // The async method private async Type myFuncAsync() { .. gets something from DB .. } // Example of how the method is consistently utili...
In ASP.Net Core, I find Claims authorization is very not-concrete method. We can add anything as ClaimType and ClaimValue pair; groups, firstname, lastname, brithdate, canAccessThisURI, isEditor, etc.. However, this approach (storing anything that can be stored as claims) will make a huge claims table which includes 50...
I'm designing a system made of a web application and database. I use the <<Entity>> - <<Control>> - <<Boundary>> stereotypes in my UML diagram. In the following sequence diagram, I already have an interaction with a system in the cloud. I want now to show also the internal database (on the same server). Shall I rep...
Backstory A scrum team is well defined. They have a PO, scrum master, clearly defined scope. The workload increases, as more and more projects are covered and need to be maintained, but it is still the same scope. Problems Team struggles with capacity, so more developers are added to the team. They pick up, the job get...
Background I am trying to develop with Webpack and JavaScript. Webpack would bundle all source code into one single file. When application becomes large, the file would be very large and cause negative impact to the performance. Webpack Webpack provided feature named code splitting which would split the bundle output i...
I just started learning about hamming codes and they're pretty awesome. I was just wondering though, are the check bits able to detect error in the check bits, as in, if one of the check bits is received erroneously can that be detected? Or is some other method required?
Under which circumstances would you deem it justifiable to use externs (i.e. global variables)? For example, in a system with 1 given state at a time, would it be appropriate to store this state in an extern?