instruction
stringlengths
34
36.1k
Let's say I have an abstract Node class and BinaryOperation class derived from Node and three classes IntegerConstant, RealConstant and CharacterConstant also derived from Node. The general design for the BinaryOperation class would look like this: public class BinaryOperation : Node { public Node Operand1 { get; p...
I understand React and Redux (at least think that I do). But the combination using the react-redux Binding package is a bit confusing to me. https://github.com/reactjs/react-redux The first thing that disturb me is the motivation to use connect. Why not just use store.subscribe(()=>{this.setState({})}) from the root C...
Let's say I am writing a simple library in JavaScript, with only a few functions: Calculate the factorial of a positive natural number Find the least common multiple from an array of integers And so on... In each of these functions, I will check if the given parameter is acceptable before performing any operations, a...
What I Want to do I'm in a process of sketching, prototyping and brainstorming to know the possibilities the code will deal with and what kind of problems I could face while writing the code. And decide how the code must behave to face the problem that solves, evaluating pros and cons of possible behaviours. What I Kno...
I have domain object User which contains simple value object 'Contact'. Contact contains only getters without setters. public class User { private Contact contact; // other methods and fields } public class Contact { private String phone; private String email; private String fax; // and geters } I nee...
I use Xcode to edit my source files, and typically a file will look like this // // Queue.swift // SomeCompany // // Created by Someone (Job Title) on 26/06/2017. // Copyright © 2017 SomeCompany. All rights reserved. // /// A queue is a list where you can only insert new items at the back and remove items from the...
Background During web development, especially on the front-end, developers must test their code to see how it looks (pretty self-explanatory right?). When doing this, the developer will examine the website not just from their browser of choice, but from a multitude of browsers. This: Tests to see if all features are i...
Consider a website like: Confused.com, which is a price comparison website that has millions of registered users who use it for price comparison purposes. These users register their details for price comparison purposes? How do you deal with administration i.e. people who work for the company in question? For example,...
My question is a little bit about branching, versioning and agile development in general, but the heart of all three is the version number I think. Currently, I'm using internal version numbers (e.g. 1.0.4). This is also what the QA gets. But what if we would need a hotfix? I can't use the third number anymore, because...
I am planning creating a small personal blog application that handles only one user - the content author, let's call that user admin. There would not be any registration option, only a hidden login page that only the admin is aware of. There would not be any options that requires registration (no commenting, no posting...
I'm a summer intern at a small company tasked with developing a prototype for a (contact) record linking microservice. After some googling I understand that the first step should be cleanup / normalisation of my input data before I can effectively start linking contacts. (I'm thinking of mapping Ben to Benedict, etc) ...
I have to create two different projects with the Entity Framework: Web API Services UI and Business Logic (MVC). Both the projects have to work with same POCO entities. I see two alternatives and would like to know the pros and cons of each, and if one of the two to be recommended as best option: Make a different ...
Disclaimer I hope I am not stepping on anyone's toes or offending either concepts' enthusiasts Background I have been looking for real differences between Service Oriented Architecture and Microservices, without finding any clear answer. I read things like: the side effects of SOA SOA being anti-pattern Microservice...
I have an application that will allow the user to enter and store (in a DB) a website URL for a company. The only requirement (as of now) beyond entry of the website URL is to validate that the URL is valid and display the URL with other company information. The application consists of a client UI that will pass JSON o...
First SE stack, I am working on a large chunk of old Java code and am finding tons of duplication and inconsistently configured/created objects because of different authors, skill levels, etc. I have implemented a few static factory patterns and am having a debate as how to make the factory configurable. EDIT: per comm...
I have refactored some code at work lately, and I thought I did a good job. I dropped 980 lines of code to 450 and halved the number of classes. When showing this to my colleagues some did not agree that this was an improvement. They said - "fewer lines of code is not necessarily better" I can see that there could be e...
I am trying to setup consul for service discovery. We have hosted our infrastructure on AWS Mumbai region (We use only one region). I was going through the consul documentation where it is mentioned that when we run consul as a cluster a minimum of (n+1)/2 nodes are required to be running. The issue is that the Mumbai ...
I have a interface DataStore, which provides access to a generic data store, e.g. a local database, webserver, etc. I want to provide a way to filter results directly in the query. How should i pass filters for the query? I thought of a map which gets passed with the name of the field as the key and the desired value a...
The following is an example using https://github.com/GoogleChrome/puppeteer 'use strict'; const puppeteer = require('puppeteer'); (async() => { // const browser = await puppeteer.launch(); // const page = await browser.newPage(); const browser = await puppeteer.launch({ headless: true }); const page = await bro...
I have used java reflection with a static map to map actions(removeElements, getLatest ...) from the front end to the corresponding database methods by name in multiple web applications now. I was wondering if this use for reflection is considered bad practice ? (I read that reflection causes hard to find bugs) If it i...
I created a generic class MyClass<T: Numeric> {...} and got errors in my functions that tried to use > and <, along the lines of "Binary operator '>' cannot be applied to two 'T' operands." I spent quite a while thinking that the problem was some syntax error I had made in the declaration. But sure enough, Numeric does...
I work on a software platform that is homegrown and, for the most part, used internally in the company but it is deployed in facilities across the globe. This system runs on a specific set of hardware, and have many dependencies, they mostly fall into the following categories: OEM hardware drivers and libraries. Custo...
If I need to write a program that Reads a json file Converts its data to yaml Writes it to yaml file and adhering to the single responsibility principle I create classes like FileReader JsonToYamlConverter FileWriter everything looks good, but then I need to create some class to invoke all these classes, wouldn't...
I'm currently developing a quite large ASP.NET application which uses SQLExpress as the underlying database. The project is currently under heavy development and is covered with unit tests and regression tests. Subversion (SVN) is used as a version control system. Those tests are very important, we need to make sure th...
I've just read the Scrum Guide as I have no experience with scrum and my team is starting to use the methodology. We use JIRA to record/track our issues, but a common process is that we get operational questions/requests through email or in person. We add those to JIRA as operational tasks (we don't have a development ...
Role based security is a very common model for software nowadays. It is very powerful but requires careful configuration to leverage the benefits of shared roles. It is easy for a mess to be made for example when the admin user simply creates a role every time a change is needed (instead of leveraging existing roles). ...
To create a method that takes an array as an argument, you would do this: public static void printAges(int[] age) { // prints ages to screen for (int x = 0; x < age.length; x++) { System.out.println("Age: " + age[x]); } } How would you create a method like this one with one exception, that it takes an ...
I'm building a small game similar to chess. I'd like to be able to reuse the structure for another version of checkers too. I'm modeling the games with interfaces (showing only relevant ones): RuleOrchestrator.class public interface RuleOrchestrator { Collection<Move> allowedMoves(Player player, Move move); } Play...
Is it good practice to express the state of an HTML element--such as whether an input's value is valid--using a CSS class? Would it be better practice to use data attributes, the properties of a JavaScript object representing the element, or some other method? Example: CSS: .error { box-shadow: 0 0 8px .1em #b94a48...
I've started working on my web application and I'm stuck at the design stage. I cannot decide which web technologies would be the most suited to this project. Let me explain what I want to achieve: 1) I need to web scrape data from a website which provides live scores for sport games (e.g. flashscore) 2) I would like t...
In my current Java EE project I've got a quite common task: Load objects from database using Hibernate, transfer them in another object structure (based on a XSD) and serialize it using JAXB. To simplify the scenario imagine the XML I want so serialize is a file with information records to requests we get. In theory th...
We are dealing with a lot of null values, now and we are wondering if there are any standards for avoiding it at some places in the code. For example I have this PHP code: class X { function setName(string $name) { $this->name = $name; } } $x = new X; //Will throw exceptio...
I sometimes read about "hiding the framework/technologies used in a web application for security reasons"... But why? Is it a real issue to publicly expose which tools I'm using to create a project? Large public web application like LinkedIn, Facebook and many others don't hide tecnologies used for their platforms, so ...
I am new to Spring as well as layered architecture. So am a bit confused as how data flows among the different layers. What so far I have understood is: Layers: Controller (which accepts requests) Model (simple POJO with dependencies, which depicts database table) DTO (expansion of Model objects i.e. flattening; with...
In programming language theory semantics, semantic is the field concerned with the rigorous mathematical study of the meaning of programming languages. It does so by evaluating the meaning of syntactically legal strings defined by a specific programming language, showing the computation involved. According to...
According to compiler definition, the compiler is a program that translates a program written in a programming language P (source code) into a program written in a machine language M (machine code). And also "the compiler is self-compiling if it is written in P". now the question is what is the meaning of the line- "t...
As per the "Software Architecture" explained by Uncle Bob, your architecture should be able to defer the framework and DB related decisions as much as possible. Consider an example of a Payroll system to be developed in Java. I assume that the core application will be a standalone jar file. The "delivery mechanism" wil...
I'm developing an app which will cater for in-app purchases but not in the traditional sense of addons for games, upgrades, etc. The app will connect to the user's profile on our API and see if they have any Payment Profiles, which we would use to pay for an item (in this case a ticket) on the website. It is my underst...
I am looking for the name(s) of a concept I heard of. I know that it does not exist in many programming languages, but I think it exists at least in C++. Let me try to explain the concept. Assume I want to define a generic collection in some programming language, and I want this collection to contain elements of type A...
Example: I'm in a coffee shop in Maine, using a VPN whose physical location is in Berlin. I know that my packets between Maine and Berlin are encrypted, so someone snooping on that coffee shop's wifi can't see what my packets say, or where the packets will go after Berlin. But can they see that the packets are going to...
Say I have a DDD application with three bounded contexts i.e. Sales, Production and Marketing. Say I wanted to setup an administration facility. The admin facility would allow superusers' to change data in the tables that are used by: SalesRepository; ProductionRepository and MarketingRepository. How would the Admin...
I have read a lot of materials regarding preferring returning values from function like this: some_class func(); over getting output by passing it by reference like this: void func(some_class& input); I have found little information regarding whether similar rule applies to class private member methods though. Suppos...
I do programs for several years. And now I know from my colleagues my pros and cons: Pros: I can solve very complex problem cons: I make overcomplicated solutions for simple tasks. Now I'm trying to fix my cons and looking for generic principles and guidelines for this question: When should I create an additional pie...
The context As a school project, I'm building a PHP and Android app for a fake company. Let's call the company "Express Food", which can talk pretty much by itself. The "daily meals" are kept by deliverymen who wait in streets for a delivery, we say that these deliverymen are inactive. When a customer orders the meal, ...
I recently read two articles regarding two different approaches for managing the underlying technologies of a system. The first one was by engineers of reddit, explaining how they gradually extended their deployment and scaling mechanisms, starting from simple python scripts to a full AWS auto scaling solution. The gen...
I recently worked in a larger project where I touched the topic of distributed systems in the c# world the first time. I found that wcf is fantastic for remote procedure calls, but how do you add event communication between services using only wcf? Here the project requirements: We had ~15 different services for diffe...
I'm making a C++ OpenSource project and I want it the more understandable and clean, so I need some point of views about doing things like this : Server.cpp: void Server::setOption(type foo, type bar) {/* ... */} void Server::start() {/* ... */} App.cpp: namespace App { void startServer() { Server s; s.setOp...
I'm currently writing the GUI for my application. As I understand in a MVC-like application are the following components for each feature: Business data: a complex object hierarchy containing all the data I need Processing code: code that works on the business data Controller: Somehow handles the conversion between vi...
I'm not sure the title is correct, so please advise if you think of a better title. The scenario is: We have an API gateway that exposes REST API to our clients (web and mobile apps). We have a "sessions" microservice that keeps track of the logged in users. When a user logs in, a new session is stored in this microse...
When doing simple server updates or submitting forms or that type of thing, I have come to a fork in the road...using AJAX: var ajax = new XMLHttpRequest(); ajax.open("post", "myserver.php", true); ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); ajax.send('entry=' + encodeURIComponent(entry)...
As I was working with a friend on a project I noticed that he created custom functions such as: function is_empty($val){ return empty($val); } function is_not_empty($val){ return !empty($val); } function is_set($val){ return isset($val); } function is_not_set($val){ return !isset($val); } and is using them in...
I am very puzzled with the obsession that many people seem to have with using Microsoft frameworks. I have seen several tutorials and projects (both open and closed source) that seem to utilize all of the additional .NET framework libraries and code when they are not really needed. To be clear, I am not talking about c...
in C#, an int data type has a maximum value of 2,147,483,647 and a float maximum value is 340282300000000000000000000000000000000 what causes these data types to have maximum values, where do those numbers come from?
I am reading up on authentication/authorization in web applications. Could anybody confirm/correct my current knowledge? Cookies: in their early version, a text file with a unique client Id an all the other information needed about the client (e. g. roles) Session: only the unique client id is sent in a file (also cal...
How does a highly scaled company serve users on the opposite end of the world? Take Facebook for example (headquartered in California). If someone hit their endpoints from a place like South Africa, how are they routed to the nearest webservers? I thought the load balancer would do this, but that doesn't make sense to ...
Background: I am working on a node project which consists of a core package and several addon packages. For the end product to work, the core package and atleast one of the addon packages should be integrated. These addon packages are basically database adapters. Addon packages have a production dependency on the core ...
We are writing a cloud application in a micro-service architecture. We have good unit and integration test coverage for the individual services and we have a set of (public) API level acceptance tests. For simplicity I will use a contrived example to step through the problem at hand. Let's say I have a Company and Us...
I am designing a 3rd-party library for developers to retrieve data from various endpoints of another system which itself has multiple APIs. Each of those APIs may contain the same type of request but return different data, which correspond to a namespaced request class in my library: api1.domain/type1/schedule.json ->...
It strikes me as weird that the column expressions (everything between SELECT and FROM) in an SQL SELECT statement come before the table references, when the column expressions depend directly on the aliases, joins and subqueries of the table references. The converse is not often the case, so often I end up writing the...
I am creating an administration facility for an asp.net MVC application. I am currently trying to create a form that will allow admin users to create roles. I see plenty of code, which looks like this online: public class RoleController { ApplicationDbContext context; public RoleController() { ...
In this question about using WCF and/or WebAPI, there is this quote: I was asking myself the same question until I found this WCF and ASP.NET Web API comparison page on MSDN (with my own emphasis below): Use WCF to create reliable, secure web services that accessible over a variety of transports. Use ASP.NET ...
I'm using Django and Django-Rest-Framework to build a simple photo sharing app/website and just now getting around to implementing a "Like" system. A couple of options I've thought about (surely there are more): In my Photo model, add a Many-to-Many like field containing users that like the photo. My concern with this...
I'm designing software that will connect to a remote service and send it requests from a local application. This remote service implements a leaky-bucket algorithm to determine whether to process the request, or return an exception. Documentation for the remote service is thorough. I can design my local application t...
I'm working on a game framework and have decided to use OSGi to bind it all together, as modularity is core to the game itself. I want the game to be run as an all-in-one bundle on someone's machine, or writing it as a server, putting the login server on an Azure instance, and having the game engine running on an AWS i...
Second Year Software Engineering student here. I want to make a file managing system for a C# notetaking app, every note will be represented by a file and will display a small preview of it, furthermore all notes should be query-able, rearrangeable and editable, the whole system it self should be portable to other plat...
I have inherited a 10+ year old project that has been handed down through many developers. Needless to say, there are many instances where there is some class or object property that no one knows what it is for or why it exists. The code base and DB scema are in desperate need of pruning. Obviously I search all code, d...
I've got a generic container class: from typing import Container, Generic, TypeVar, NamedTuple import sys fixed_typing = (sys.version_info >= (3, 6, 2) or (3, 5, 3) <= sys.version_info < (3, 6)) T = TypeVar("T") _Interval = NamedTuple("_Interval", [("start", int), ...
I read a bit about DDD since at work I came upon a web application, supposedly written according to DDD principles. Some things which I see however in this application look to me totally absurd. As I understood, the main point of DDD is about "ubiquitous language" shared by analysts and developers alike, such that the ...
Most functional languages use linked lists as their primary immutable data structure. Why lists, and not e.g. trees? Trees can also reuse paths, and even model lists.
I am creating a multiple wrappers/layers API in Java that go like this public class Layer1<T extends Layer1> public class Layer2<T extends Layer2> extends Layer1<Layer2> public class Layer3 extends Layer2<Layer3> with methods like public T sees(){ return (T) this;} within each layer What is the correct way for t...
I have a client-server system modelling an interactive business process with the following four constraints:- The client may have stale data, and/or the client may be untrustworthy. All client-side commands must be validated on the server before their effects become "truth". The client's user experience (though not no...
It's considered a good practice to commit to git a lot. Sometimes this is necessary where git is used as a delivery mechanism to test in the cloud. But my git history gets cluttered up with lots of commits, each with a very small and almost meaningless commit comment. What is the best practice? To reuse the same commen...
I have a solution with 10 projects, I used to distribute this as an SDK with an installer back in the day. To change that in VSTS I added the steps to create a package per project, every time I make a change, a build is triggered and a PS script change the version of the nuspec files, in the end the packages are pushed...
I'm thinking of whether it is possible trying to apply project management methods and frameworks, e.g. PMBOK, PRINCE2 or something like RUP for software applications, that are still under active (iterative) development, but do not have a specified ending . As I've learned, a project is always a temporary endeavor, so s...
We need a content management system, but we need alot of features that are not available on the market now: integration with Azure AD, integration with our phone system, and a couple others. I'm having an issue figuring out how to implement a basic feature: allowing the user to add pages to their directory. Here's my q...
I work in a project that uses (Spring) Dependency Injection for literally everything that is a dependency of a class. We are at a point where the Spring configuration file has grown to about 4000 lines. Not long ago I watched one of Uncle Bob’s talks on YouTube (unfortunately, I could not find the link) in which he rec...
Here is the work flow of a class of my program: Server class instanciation -> Creating socket -> Binding socket to addr:port -> Listening -> Handling clients Should I put all that stuff in the constructor or in separated private functions ?
I'm writing a small microservice-based application. One of the services is assigned the task of querying an external API and processing the JSON response (filtered list of houses). Since I'm using Protocol Buffers to serialize the message that will be sent to the message broker I need to convert the JSON output to the ...
I want to implement a more robust authentication service and jwt is a big part of what I want to do, and I understand how to write the code, but I'm having a little trouble understanding the difference between the reserved iss and aud claims. I understand that the one defines the server that is issuing out the token an...
I have such problem: the interface with no in and out parameters. public interface IIndexer { void FillIndex(); } It should work differently for different kinds of activities( comments, likes and so on). And when I apply IoC principle through dependency injection (via Ninject), my resolver cannot resolve me Commen...
How should looks update method signature in aggregate root? For example I need to update user address. I have multiple ways to do this, and don't know which is better ("domain driven design way"). First way is to create method in User which get UserAddress as argument: public void updateAddress(UserAddress address) { ...
I have some problems figuring out how I should design an application. On a production line there multiple stations. The products will move from one station to the next. Each station will execute some task on the product. The tasks should be executed in parallell, so all stations that have a product should execute it's...
I recently asked a question on SO where I was trying to understand how to catch an exception in a piece of code which runs indefinitely. I was initially expecting that try: the_code_which_runs_indefinitely_and_which_raises_an_exception() except: print('the exception in the code which runs indefinitely was caugh...
Consider this simple method. public async Task AddItem(TodoItem item) { if(item.DueAt < DateTime.Today) { item.ValidationMessages.Add( "The date is missing!" ); return; } var mappedVersion = _mapper.Map<TodoItemDto>( item ); await _todoRepository.Insert( ma...
I'm reading articles about REST including a tutorial. I've seen this site http://www.vogella.com/tutorials/REST/article.html, and there is a part for explaining the rest as: In a REST based architecture, you have a REST server which provides access to the resources. A REST client can access and modify the REST resourc...
Suppose I want design and implement a a large and complex file format, like pdf or docx; how do I have to structure it? How can they contain so many different data types like images, macros or graphics? Edit: for structures I mean the ways for storing different data types, I don't think that a plain binary file is so v...
Very often when coding in Python (or any language where type is not specified) I run into the following problem: I want to write a function that can accept either a thing, or a container of such things in general. For example consider this subset function: def subset(df, months=all_months): return df[pd.DatetimeInd...
Here is the scenario: We are running a microservices style architecture on AWS using API Gateway and EC2 instances. Let’s say there are five services: Photo Service, Topics Service, User Posts Service, User Messages Service and User Profile Service. There is also an SQS Consumer service, the “Message Worker”. Each micr...
I need to write a Software Quality Assurance Plan (SQAP). I am familiar with the waterfall structure and I have seen SQAP samples based on waterfall model. I also know how TDD works, but I could not find any SQAP that is based on TDD/agile. I assume a SQAP for a TDD is more minimal, but still can anyone please clarify...
Why is the sorted() method on Stream not named sort()? list.stream().sort()
I'm having major troubles trying to get rid of this switch statement. To put a little of context first, I'm working with asynchronous batch operations. These operations can be applied to any entity in the system. You just have to send a different namespace. Example: "jobs": [ { namespace: "client", request: {"i...
We're in a process of moving from a huge old monolithic architecture towards microservice one. UI-centric Product Our product (which is mostly a large single-page app) is quite UI-centric. Thus the current codebase includes lots of automated UI tests. Objective: Continuous Deployment We expect to have a lot of microser...
I am programming an application and am having trouble finding a good architecture for some of its components. As part of the front-end app, I have a user authentication system and an API that allows users to perform certain actions on a server. I have built the following components: (This is in javascript, but I imagin...
Our documentation team of about ten people recently moved from SVN to Git. In SVN, everybody worked on master -- a model I've always hated, but I wasn't able to bring about that change. As part of the move to Git we've agreed to fix that, but we can't do it just yet (waiting on build changes that will allow builds fr...
I spend a lot of time answering SQL questions over on SO. I frequently come across queries of this ilk: SELECT * FROM person WHERE birthdate BETWEEN '01/01/2017' AND '01/03/2017' SELECT * FROM person WHERE birthdate BETWEEN '2017-01-01' AND '2017-03-01' SELECT * FROM person WHERE birthdate BETWEEN 'some string' AND '...
In Hibernate ORM & Spring Boot, during the SessionFactory creation, SQL DML statements can be executed to create tables and/or insert data via files such as import.sql defined in the javax.persistence.hibernate.hbm2ddl.import_files property. As I understand, using this feature is particularly useful for inserting refer...
I am working on a Review System and I am having doubts about how to handle storing data in the database. For this review system, there are three different ratings the users can input, I will call them ratingOne, ratingTwo and ratingThree. My current solution is having three different columns in the database called, res...
If I have an algorithm and part of it has a known worst case numerical value, which is reasonably small compared to the rest of the problem, is it ok to argue that part as O(1)? E.g. If part of the algorithm involves building a linked list of characters out of a string, where the string may contain each of the ASCII ch...
I feel confused about the three relationships Association, Aggregation and Composition in UML. I need to finish a project soon, until it became less unclear in my head, is it okay to use only Associations ?
We have a mature product that we reuse for new projects. For one project, some tasks were created for already working features. Those tasks were all assigned 1 SP each. So, just as a sanity check, I went ahead and tested a release version of our product in order to close the said tasks. Now, since I didn't do any work ...