instruction
stringlengths
34
36.1k
The following code is given: class Warren { private const int MaxRabbitsInWarren = 99; private Rabbit[] Rabbits; private int RabbitCount = 0; private int PeriodsRun = 0; private bool AlreadySpread = false; private int Variability; private static Random Rnd = new Random(); public Warren(int Variability)...
Background: I am developing a messaging framework. This framework will allow: sending of messages over a service bus subscribing to queues on the message bus subscribing to topics on a message bus We are currently using RabbitMQ, but I know we will be moving to Microsoft Service Bus (on Premise) in the very near f...
I am stuck at how to classify Dropbox and other cloud storage services within the ISP (IaaS,PaaS,SaaS) model. At their core, such services provide a cloud-backed file system which can be read and written to from any location as long as there's a connection. A file system is sort of Infrastructure in that it's an esse...
Good morning. I'm developing a media player software with MVC pattern. My question is about the reproduction of media elements. I think we need 3 software classes in order to do the design. These classes are: PlayerRegister: A class in Model package that for each user we have a unique instance of it saves media element...
I'm working on a project where I got an architecture with multiple "Microservices" communicating with each other by using an event bus (RabbitMQ). I got an Web API-project set up for each service so the outside world can send commands using REST-calls. When my Web-API receives a call, it sends the command down to my do...
These days a question popped out in my mind: Does the way we Javascript go against almost everything that is considered a good practice in traditional Software Development? I have a series of question/observations related to this statement, but in order to respect StackExchange's format, it will be better if I split ...
In our company several teams will work on different components of several projects at the same time. For example, one team might make make specific kinds of software (or hardware) for some project(s), another team another specific kind of software. We use Jira projects to host issues for specific projects and Jira boar...
I have the following setup: An object A running as a separate service with its own address (implemented via Pyro package in Python). An object B running as a separate service with its own address. Object C used as a vehicle to transport data between A and C. Use case: A creates C and sends it to B for processing. W...
I am using GitFlow for my development conventions. Generally speaking, I create a user story and an matching feature branch off my develop branch and work on that. Once the story is complete, the feature is complete and merged (rebased) back into develop. However, I am now running into the issue where my feature is r...
I have one design issue and can't seem to find a good answer by my own. I am required to build application with some specific features which doesn't really matter because I implemented most of its business logic and behaviour. My problem is that at some point, this applications needs to read some data from the database...
I'm working on a JavaScript utility where I'm trying mix two colors in different ways. I basically want to cover the blend modes provided by Photoshop / the W3C spec on compositing and blending (which are essentially the same). The algorithms provided in that document aren't too useful for me tough. First, I want to us...
This might have been covered in another thread. I didn't find it though.. Today, with Sass I have 2 options of styling my website. Lets see examples Example 1 <button class="button main center">Submit</button> I have 3 classes, each is quite abstract.. collisions may occur. For example - bootstrap has a selector .clo...
At my workplace, we use an SVN repository for the source code, which holds the main application and some other projects, and for the main application it is structured like this: - trunk - app - tags - app - 16.2.0 - 16.3.0 - ... - branches - app - 17.1.0 - 00_master - 01_feature ...
There's this application whose official website requires that people provide their email and agree to a EULA before they send you a download link. The EULA forbids redistribution and publication of derivative work. Still, you find many derivative versions of that application in GitHub projects, some of which have made ...
Enterprises are increasingly adopting DevOps methodologies for development of software. A couple of common outcomes of this are that: Application teams are more cross functional in nature, with operations and support staff working in self-contained teams alongside developers. Developers have an increasing support role...
Before release a new version of the software, which is a web application, my company creates a release branch. The QA team tests that branch and reports some issues. Should developers commit the fixing code to that release branch or a new bugfix branch that is merged to the release branch later? For more details, my co...
I'm working on web app that communicates with a locally installed desktop application to get certificate information from the user machine and perform digital signatures. Currently it's possible to auto generate keys and perform digital signatures with these auto generated keys in javascript using window.crypto. Howev...
I was checking out the App Service on Azure and in one of the tutorials two API apps are created, one for data and one to be accessed by external apps. It's not clear to me from the tutorial what the real benefit is to having this separation. Since I'm assuming all the Data API is intended to do is talk to a database,...
I have a problem with the handling of an order once it has been confirmed and has already been shipped to customers. Suppose our initial order is as follows, and we don't know which customers will shipping products Once the order is confirmed the order is sent to different customers: Now Suppose that once the product...
I'm working on the creation of a software and product documentation in a wiki format. It will include the documentation for all the company products. After some research, we decided to use the MediaWiki platform and create a private wiki accessible from our internal network. This documentation will include mainly softw...
Following the article Programmers Are People Too by Ken Arnold, I have been trying to implement the progressive disclosure pattern for an API. Basically, the idea mentioned in the text is to break the API into categories and only present the user with what he or she needs. The rest is hidden, reducing complexity for so...
What is the best approach to testing a service when you add a new configuration? For example my service offers a service to a customer and based on the customer configuration, it will offer a different type of service. E.g. if the customer selects a particular currency they are offered a 20% discount compared to anothe...
When I first saw this meme: I thought to myself, yeah right, but now I am not sure any more. So was template meta programming in C++ discovered by accident as the meme claims or was it intentional? Did Bjarne & co actually make it without realizing the potential?
As far as I understand, the big idea behind CQRS is having 2 different data models for handling commands and queries. These are called "write model" and "read model". Let's consider an example of Twitter application clone. Here are the commands: Users can register themselves. CreateUserCommand(string username) emits U...
Basically, I was debating in my head how an API and a protocol are different. After thinking about it, I come my newbie conclusions that I believe they are pretty much the same, except that protocols are more like an API that is widely accepted and used. For example, both API's and protocols define criteria and specifi...
I'm currently toying around with a very large project. A interpreter for a simple scripting language. After weeks of planning, I decided that the best course of action would be to prototype part of the interpreter in Python, and then port that code into C. I started off by writing a simple lexer based upon some EBNF I ...
I'm a beginner in programming and I don't have a good grasp on terminology. I'd like to know if source code written in a compiled language like C or C++ is considered a program? If not, can anyone explain why?
I'm dealing with a lot of functions like the one below and I'm unsure of what kind of unit tests should be written for them. public void UpdateEmployeeClockIn(int employeeId) { var sql = string.format("Update Employee set ClockIn = GETUTCDATE() where employeeId={0}", employeeId); db.ExecuteNonQuery(sql); } I'm thinki...
I want to just say that it's time O(n) and space complexity is O(n!), but I am not certain. Can anyone confirm this or tell me what it is? https://docs.python.org/2/library/itertools.html#itertools.permutations
In this scenario. I have an application targeting two countries, however same language. The code is the same, at least, in this stage, can't predict the future. Each country has an isolated database. The distinction is made through the subdomain (e.g. pt.mywebsite.com) Currently I am thinking about using the same cod...
I have been developing software for the past three years, but I just recently awoke to how ignorant I am of good practices. This has led me to begin reading the book Clean Code, which is turning my life upside for the better, but I am struggling to get insight into some of the best approaches for writing my programs. I...
I'm on a software development programme in financial services - with 100 developers, plus testers, BAs, PMs and other support staff. We've read through Implementing Lean Software Development, and The Phoenix project, which both talk about identifying the bottleneck in your flow, and optimising it away. (Some similarit...
I have been wondering what it is that makes the Iterator special when compared to other similar constructs, and that made the Gang of Four list it as a design pattern. The Iterator is based on polymorphism (a hierarchy of collections with a common interface) and separation of concerns (iterating over the collections sh...
I am currently working a REST API design and I am looking for a way to add an advanced ACL management, beyond what Let's consider for instance that I have a route which is the following : /profile/{user} Let's say this route might be call with GET or PUT methods. The GET method have to a controller to display the us...
If there for example is an object "SoccerTeam" with a TeamView and a TeamController, and that team has a list of "Players". So there exists also an object "Player". Does this object also need a "playerView" and a "PlayerController" ? If yes, should "TeamController" use "PlayerController" ? And should "PlayerView" upda...
I currently work on a hobby project which I use to learn more about Android/Java programming and programming in general. Recently, I decided to integrate jUnit into the project. Just getting it in there wasn't much of a problem, but actually using it was. I've read that a unit test should be the definition of what a me...
I'm building a Web API. To give meaning to my controller methods I want classes that specify what properties are used for each particular operation. This would make the code easier to understand, and auto generated api docs would also be more meaningful. Is there an existing pattern or at least semi standard that can g...
These articles explains how to give credit for CC-licensed work, but I can't information on where to give credit. Suppose I want to use an icon on my commercial website -- I can't exactly credit the author next to every 16x16 icon I use throughout the site. Is it fair/legal to have a sort of licenses/credit page linked...
There is a lot of optimism around Blue-Green deployments, particularly from luminaries like Martin Fowler. The challenge with a financial services application, is that to make a blue-green deployment work, you have to guarantee that the old app will still be able to transact whilst the new app is being deployed - whic...
I have a class like this: class X { X (databaseconn, httpclient) { this.httpclient = httpclient this.databaseconn = databaseconn } public func1(a, b) { // ... } public func2(x, y, z) { // ... } // ... public funcN(p, q, r) { // ... } } There are very few methods in the class t...
In use case modelling, if I have functions that have to be done by the system itself (without actors), how can I represent them? For example, sending SMS message, compute bus route, or notify someone when a change occur.
I have read this in many project description - like here or here. Looking for an explanation of what this means, I simply get more pages that discuss a project's "Y-O-Y commits". What does thie metric mean? What is the use in reporting this metric?
I was reading Why are websites (even this one) sometimes "Down for Maintenance"? , and it dawned on me that my industry accepts planned downtime asa given despite the disruption to staff and the (mostly hidden) cost to the business. What strategies can I use to achieve zero (planned) downtime in a database-backed web a...
Due to these answers, I've decided to implement MVC (or a variation of it) into my application. But the more I read the more confused about this topic I get. Some people say the business logic belongs to the model, some say the model should only holds data/a state, some say the logic should be entirely in the controlle...
What is the difference between Bridge and Factory Pattern? both the pattern seems to instanitae the class depending upon the logic from the client side. Factory Pattern interface IFactory { void GetProduct(); } class Germany : IFactory { public void GetProduct() { Console.WriteLine("germany"); } } ...
So I've been learning DDD and am attempting to refactor an old project using this approach. It is a fairly small app to register employees for events. These employees are initially populated from the DB, registered, and saved. One business rule says that if an employee is marked as CannotAttend = true and they show up,...
How can I disclose the source of a software with Mozilla Public License? Do I have to give a link to the source code from the software? Is there any problem to give the source of original repository (my software is copied) instead of modified version (changes made by me)?
I would like to store history of changes in table and also remember author of change. I created temporal table. This table contains ChangeAuthorId column which value I update every time when table is updated. I would like to display every changed value separately in one log row with date, old value, new value, author o...
What data structures and algorithms are suitable for event stream correlation? Specifically, I am looking at these two use cases: X occurrences within t seconds grouped by some variables (v1,v2). For example, 5 failed login attempts within a minute grouped by service such as SSH or FTP and IP address. Event A is follo...
I have a project in Angular1.x using a lot of SVG files. I have no idea what to do to SVG files to prepare them for production. I don't want my page to invoke 50 calls to different SVG files. So what are my options and which tools do I have to accomplish them? I use npm scripts to build my project.
The question seems to be quite vague, so let me give some background: I have given the concept of design patterns some thought and stumbled upon the classification used by the Gang of Four: Creational Patterns Structural Patterns Behavioural Patterns Since design patterns are intended to be solutions for common desig...
I am about to release an Android app into the PlayStore. Currently my about dialog says: Application Name Copyright © 2016 All rights reserved Owned by My Name myEmail@address Used LGPL3 Library: MapsForge Version 0.6.0 Used Icons from: https://icons8.com Is that sufficient or are there more things I have to put in ...
I just wondered why most people use the .h extension in their C++ Projects, even though the standard is actually .hpp? Isn't this a little stupid? I always thought precision in differencing between those is important?
Intel 8085: I'm having big troubles understanding addition or subtraction with more than 16-bit numbers in Intel 8085: 1.) If I execute ADC M instruction then this should happen: (A)<--(A)+((H)(L))+(CY) , right? How can be 16-bit data (HL) transfered to 8-bit register (A)?
I am experimenting with using a private NuGet repository and jenkins to deal with dependencies. Let's say we have exe A and libraries B,C and D. Exe A depends on library B which depends on C and D. On push of code changes to B,C or D jenkins builds and publishes a separate NuGet package for B,C and D to our private rep...
I have two process ProcessA and ProcessB. I want to run these two process independent of each other. There is no relation between them at all. Each process should have a different Properties object. Each process should have a different thread pool configuration since they can be run in multithreaded way if needed ind...
Polyglot Programs strikes me as pretty confusing and error prone. Right away I don't see any use to it besides "showing-off". Wouldn't that be a bad programming pattern, since it's not modular? Is there something that can be implemented with it that's cleaner than designing software applications as suites of independen...
I am looking to create a "Composite file" in C++, basically a composite file is a file containing files, (examples: .docx, .jar, etc) these files can usually be renamed as .zip and opened with a .zip opening program, but the program using them don't usually unzip them prior to use, nor do they compress them after use, ...
I am having trouble differentiating between Big Data vs Data Science. From what I've understood so far, both are buzzwords for the old statistics job. Where does machine learning fit into this?
I'm currently working on a requirement to implement logging in multiple projects and require to develop a enterprise level logging application that can be using in n number of projects. Present Scenario: What currently is happening is for every solution comprises of 3-4 projects, a logging project was developed and Log...
As I can see in recent releases of akka-http, successor of spray, spray-routing's approach of using shapeless HList was replaced in favor of self-included Tuple What is the motivation for this transformation? Has this done just for self-inclusion or pure Tuples without intermediate generic transformations to HLists a...
Domain objects (aggregates and entities) are only exposing behavior and no dummy getter() or setter() methods. If I don't want to use an ORM in a repository which is capable of extracting internal state by means of reflection, then how a repository is supposed to get internal state of an aggregate?
There are huge benefits to pure functions in functional programming, but can the same benefits be obtained in imperative programming with heavy use of the service pattern? I ask because I want to find a way to map ideas from pure functional programming to imperative programming focusing on using stack space or immortal...
I work on a large software programme - 100 developers in financial services. The common wisdom of Continuous Integration is to get feedback early from your changes. The common wisdom from Continuous Delivery is that by getting good at releasing small chunks, you reduce the risk of failure, because you can roll back e...
I'm not sure what to do with the following: We take data from an external tool within our own tool. This data is written in Dutch. We are writing our Java code in English. Should we then translate this Dutch to English or keep it Dutch? For example, we have 2 departments: Bouw (Construction in English) & Onderhoud (Mai...
One of my NPM modules is, frankly, pretty lame, hasn't been worked on in years, has no watchers, no stars, and only ~50 downloads per month. I'm going to abandon it, and eventually delete it so it doesn't clutter up my github page. Just in case there's one project in the world relying on it, is there a good way to l...
TL;DR - Is it ok to share a POJO library between services? Generally we like to keep the sharing between services strictly limited to none if possible. There has been some debate whether or not the service that is sharing data should provide a client-library for clients to use. The client-lib is generally optional for ...
So at a high level my use case is as follows - I periodically (every 24 hours) get a very large file (size can vary from MBs to 10s of GBs) which I need to process within 24 hours. The processing involves reading a record, apply some Business Logic and updating a database with the record. Current solution is a...
I'm working on a quiz system that will allow users to enter text as an answer. The question could be something simple to start with, looking for a short phrase, or a select few words as the "correct" answer. Having a single correct phrase however could be limiting. It may be that the user misses out a few words, write...
I'm building my own utility functions to master ES6: const contains = (array, value) => { return array.indexOf(value) > -1 } const keys = (object) => { return Object.keys(object) } const find = (array, value) => { return array.filter(item => { return item[keys[0]] === value[keys[0]] })[0] } So far, I've ...
I have a use case where I display variables in a PDF file. But to get there is not simple, but I could do something like this: /* * takes product model number, retrieves, processes, formats values * returns $variables, ready to plug-in to view with no further processing */ $variables = $this->repository->getVariabl...
Let's say I have a factory class that creates some series of concrete types. I've documented all of these classes in a UML static class diagram. How do you communicate the relationship between the factory class and the types it creates? Normally you'd use aggregation or composition, except that the factory doesn't actu...
I'm starting a project with Django, previously I've used Yii and Rails and they have tools that will take a DB structure and build models for you based off the DB structure. From what I've read Django seems to be the other way round in that it builds the DB from what you put in your models. While Django is best suited...
I have several git repositories for a web project that share a library of common code. I don't want to repeat the common code inside for each repo. What are some ways others have solved this problem? Git submodules seem to get a lot of hate because they tend to cause more problems than they solve I could just have a se...
I'm writing a compiler that compiles to C. This means that most of the time I piggyback on top of C for optimisations and generating code for multiple platforms. Right now I can think of a few reasons why it might be beneficial: I can perform specific optimisations for my language It will be easier to translate the si...
When we load a register or memory location with a value (e.g. MVI 3A or MVI 53), what initializes register or memory location with that specific value? It is the CPU who performs the initialization, right? But where are those values drawn from?
I often write database intensive applications and discovered the gateway pattern which seemed to fit my needs. My problem now is that many of my models are compositioned of other models. For example I have an User model and an Order model which each has an own Gateway. Interface for User Gateway: interface IUserGatewa...
I'm developing web application using ASP.NET Core. When I use project template Web Application with Authentification: ApplicationDbContext class generated: public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) ...
A coworker and I are having a debate. In our app, there are components that behave slightly differently based on how we want it to be presented. Thus far, we have agreed our inheritance should look akin to: Component / \ Fixed Resizeable wherein Fixed would have a size property and Resizeable woul...
I am currently working on a web application page, my boss sees the changes online while i still make the changes, sometimes the page is shown to some clients in order to get feedback while it's still on development.. At this point i have added a self-signed certification and of course the browser throws the warning abo...
Hope your day is going well. I want to make the following composition of two objects with the same inheritance root: There will be 3 basic operations on the Wallet class: add, getCards and getPaymentCards. getCards should return both Cards and PaymentCards. This is a place where I've faced a problem of how to store th...
My plan's to develop a module for easy customer KPI handling across projects. It should consist of a small SDK to put 2-3 lines of code in the project, a "template"/model for a SQL table (code first DB) and a small frontend to see the most crucial things like clicks/item and so on. I thought about storing everything in...
When I review database models for RDBMS, I'm usually surprised to find little to no constraints (aside PK/FK). For instance, percentage is often stored in a column of type int (while tinyint would be more appropriate) and there is no CHECK constraint to restrict the value to 0..100 range. Similarly on SE.SE, answers su...
The author here states that: Share state between processes. Run a long running batch job in one Python interpreter (say loading a few million lines of CSV in to a Redis key/value lookup table) and run another interpreter to play with the data that’s already been collected, even as the first process is streaming data i...
I want to write a library for Mechanical State Estimation of a vehicle. This is, estimate variables as position, velocity an so on, using the information provided by different sensor measurements (GPS, IMU, ... ). These are things to keep in mind: I am not a very skilled programmer. The estimation algorithm will be th...
While learning about Redux, the God-object pattern(or anti-pattern) came to my mind- both have a single big object holding all the app data and methods to manipulate them. But Redux has put some constraints like making the Object immutable and events pure functions maintaining strict signature. So the question came, is...
I'm developing a desktop app (using Node.js and Electron), licensing the code under Apache License v2.0 It's possible to add a module, licensed as Lesser GPL v3, to my app? I know that compiled LGPL libraries can be used on any type of projects (including commercial projects), as long as the linking is dynamic. Does t...
We have a ratings system in our website that allows users to provide feedback to 3 different questions about a user. We currently calculate the rating using averages using the following query on our RDBMS: SELECT AVG(question_1), AVG(question_2), AVG(question_3) FROM ratings WHERE user_id = 1 This query does not scale...
Is it OK to have functions that have single statements? I usually make functions that have single statements. I believe these increases code readability and i am able to write code faster as they make code more like natural language. These functions are often utility functions I call at more than 2 places, at least. Re...
The way many design patterns are described in the classical literature is somewhat different from their implementation in dynamic languages such as Javascript. The presence of some features like first-class functions makes some pattern implementations structurally the same, what sometimes makes it harder to distinguish...
I'm implementing a platform where users can create an account with my system and use it to login. Also I allow them to add any external login (social login) such as Facebook, Google, Twitter and so on. The mechanics is similar to what Stack Overflow offers (Edit Profile & Settings > My Logins). This is what I came up w...
Here is a bit of context: I am practicing TDD for a new application that will target .NET 3.5 CF and .NET 4.5.2 FF. I might have some part of the code that use polymorphisme to decide at run-time a strategy (the design pattern) to use while running on a .NET 3.5 CF machine and an another running on a .NET 4.5.2 FF mach...
The organisation I work for currently uses web deploy to release to different environments. Configuration of web applications (connection strings, service url's, and so on) is managed using solution configurations, with associated app.config transforms. With debug, three test environments and production, there are fi...
I'm currently working on the project with the new team and they are using Repository pattern which is new to me. In this repository, they're currently doing 1.If we are offline, we will load data from file 2.Otherwise, we will make an api call to get data from server. I did some researches and noticed that Repository...
Given a list of transactions like: A -> 10 to B B -> 10 to C The naive way to settle the transaction would be: C owes 10 to B B owes 10 to A But the same transaction could be settled by: C owes 10 to A I am representing each transaction as an object: { amount: Number, account: Object, linkId: Object } So, f...
Given the file path: /some/path/abc.txt The filename is "abc.txt", and extension is "txt". What is the "industry standard", unambiguous name for the "abc" part? For reference, in both java's older java.io and newer java.nio libraries, filename means "abc.txt", and there is no term (ie the library APIs don't support) ...
Outline I have an application that loads data from a database. I'm not talking about client data here though, I'm talking about application configuration. The database will therefore come with some default setup, which I want to remain unchanged so that future updates can just be imported and overwrite that setup. I ...
The book Software Metrics A Rigorous and Practical Approach defines measurement as ...the process by which numbers or symbols are assigned to attributes of entities in the real world in such a way so as to describe them according to clearly defined rules. but what does it mean by "clearly defined rules"? Does th...
Everything discussed here will refer to Intel 8085 (8-bit architecture). When using two's complement number "conversion" : 1.) If we take SBI 0F (subtraction) for example; immediate value 0F(hex) or 15 is subtracted from A register, which is loaded with 3C(hex) or 60. How will the microprocessor know whether e.g. 3C is...
I know it is best practice to split of your "global requirements". Which is something I do when documenting in Confluence. However, when coming to grooming with the development team, I don't really know how to best incorporate these in to our User Stories in Jira. The obvious approach would I guess be to add them as ac...