instruction
stringlengths
34
36.1k
One of the OOP principles I came across is: -Encapsulate what varies. I understand what the literal meaning of the phrase is i.e. hide what varies. However, I don't know how exactly would it contribute to a better design. Can someone explain it using a good example?
Let’s say there is a REST API which allows users to create objects. These objects have a name. The name doesn’t need to be unique among all objects and doesn’t have any special meaning within the API. Should the API strip whitespace before creating the object? Pro stripping Most of the time whitespace (at least leadin...
I've developed an SPA using AureliaJS. We use team Foundation server to service our source control, but that doesn't really help with good versioning practices. For instance, with our WPF applications, we run a server build that adds a new build folder with a new version. This is helpful obviously because if we change ...
I want to make my application available in many languages. I started using Resource Files, but there is a little problem with them. I want other people to have access to these files. Visual Studio creates .dll for each file and that is not very easy to use. I want people to be able to see language files in an easy way....
Wikipedia says that the lexical process is often divided into two phases. The scanning process, and the evaluation process. Wikipedia defines: The scanning process as: The first stage, the scanner, is usually based on a finite-state machine (FSM). It has encoded within it information on the possible sequences of char...
I'm taking a comparative programming languages course and have learned the bare basics of variable scopes with respect to stack frames -- e.g. static and dynamic links, offsets, etc. as in the image at the bottom of this page for example. In our texts (two: Understanding Programming Languages by Ben-Ari and Concepts of...
I'm building components in Vue.js. They look like this: <template> <form :schema="form.schema" :options="form.options"></form> </template> <script> export default { data: () => form: { schema: { // array containing form fields } options: { isHorizontal: true, hasLabels: false ...
If I have a variable say x and set it to x=2 and then increment it, it happens in some systems that the variable after a number of increments reaches a max value and then resets back to its lowest value. Is there a general name for such a variable? Similar to "counting in a ring" or a modulo count for example x=1 x++ /...
If so, what is meant by not instantiable? If not, what other restrictions apply? What is the advantage of declaring a method as not instantiable in a supertype? When is this useful?
I am a beginner on DDD, working around small, simple domains in order to get my head on all the principles of design. I have this simple domain: institutions (Institution) and their available WiFi spots (Place) are kept in the database. No place can exist without an institution. Institution has manager user - assignee ...
I am creating new business web application and I want to achieve: Use the best technologies from their respective realms. I want reliable backend framework with solid ORM. And I want the most advanced SPA (single page application) framework with the use of most up to date HTML and Javascript features for the frontend ...
I was introduced to genetic algorithms recently by this MSDN article, in which he calls them combinatorial evolution, but it seems to be the same thing, and am struggling to understand how combining two potential solutions will always produce a new solution that is at least as good as its parents. Why is this so? Surel...
I am currently preparing a presentation for my software engineering class, in which I want to present the idea of package dependency management in Java on the example of "radial encapsulation" (http://edmundkirwan.com/general/radial.html). In order to give my course a more relatable introduction to this topic, I would ...
We are a project that for external reasons has to run in a Scrumish fashion. We consist of two subprojects : A backend data and services provider that I am a part of, and a UI+BPM layer that interacts with it. The backend also serves a few other consumers and both parts are implemented in two completely separate stack...
Objects tend to confuse me some. In understand the concept and use, certainly, but I feel like the functional paradigm is somewhat restricting my use of them. At the moment, I'm creating a simple code for a game of cards. Each player might have a simple object, like this: object player { name = "Steve"; score =...
Suppose I have a class A: public class A{ public void a(){ } } and class B use A: public class B{ private A a; } Should I encapsulate A in B: public class B{ private A a; public void a(){ a.a(); } } then new B().a(); or just let users of B access A directly: public class B{ priva...
I currently work for a company that has hired me to manage a website that has been installed by a former developer. I have access to the cpanel host and hold 100% authority to the website. with that being said, I barely know how to assemble HTML and CSS into a working blog theme on Tumblr. where shall I get started on ...
I have a “whiteboard” question. Technically I’d like to ask you about one thing I’m not sure in my design, but if you have time for a quick review the rest of the design - that’d be great. Every tip matters to me. So… I’m working on a simple game, turned-based (not an action game). Something like chess. For the client,...
How do game makers/engines like Buildbox, GameSalad, Construct, GameMaker, etc work in principle? I am not interested in getting a list of technologies (programming languages, APIs, etc), but how - from a software engineering perspective - do these programs convert the user's interactions into exportable code? What I'...
For a prototype project I've created an Angular 2 application with simple CRUD functionality using Auth0 to handle authentication with a back-end containing a Web API (core), Service and Repository project. I've chosen to use an Auth0 database to store all the user information (and not an internal custom table) because...
Recently, i have shifted from ASP.NET web-forms to MVC based projects. I was thinking about the state management is working for a MVC project. How the MVC page controls are able to retain the state upon any action such as click, checked etc. I was wondering, if there is any DEFAULT state management pattern for the MVC ...
There's a passage in Walter Isaacson's biography of Steve Jobs where Jobs moves Andy Hertzfeld to the Mac team by unplugging his computer and driving it over to the Mac building. This got me wondering: what kind of computers did the Mac team use to develop software? Clearly it's a standalone machine, since it can be un...
I am rather new to the concept of MVVM in C#/.NET WPF projects. The way I understand it, the view-model is supposed to lessen the amount of code-behind required to display data on a form. I try to do as much of the interaction logic as possible in the view-model, so any objects I will use get passed into the view-model...
Like the title says, is it a bad practice to create/generate the Object.equals() method because I need it in my unit tests, but not in my regular code?
Looking at posts such as this on StackOverflow, the consensus seems to be that you should hide incrementing ID's from external API's for security. However, I'm having trouble working out a good implementation. I don't want to use Guids as the ID, because as stated here, it leads to page fragmentation and when I did it...
If I have an abstract class Drink which has a derived class Coffee, what would the copy constructor for Coffee look like? If it accepts a reference of Type Coffee as a parameter then I wouldn't be able to pass an instance which has been instantiated like this: Drink* coffee = new Coffee(..); But if I accept references ...
If createWorld() is really long and I need to split it, I can split it to createLight(), createEarth(), createPlants(), and createAnimals(). So, naturally I do: function createLight(){ //work 1 } function createEarth(){ //work 2 } function createPlants(){ //work 3 } function createAnimals(){ //work 3 }...
I'm writing a very simple extension method that attempts to cast objects from one type to another. The intent of having this method is very similar to Int32.TryParse(string, out int), which allows the user to see 1) if the conversion succeeded, and 2) what the converted object is, all in one line. Because this method w...
I'm developing an whole ecosystem with an OAuth2 Provider, a Backend Server and a Frontend Server. OAuth2 Provider: provide only the authentication/authorization for the user, and a few other general purpose service. Backend Server: Implement all the logic and the models for a specific context, and is a OAuth2 client....
I've written a command line tool and I want it to print out the current version of the program if I type in the --version command. I've got a git repository setup for my program so I figured maybe I could somehow hook into that to get version information from tags or something? What happens when I type in program --ver...
I'm part of a team asked to perform some predictive analysis with a huge relational database. Data is a mess. Documentation ranges from mediocre to incorrect to absent. Information is scattered all over the tables. For example, if I want to match addresses with telephone numbers, I can query three or four different tab...
In SaaS multi-tenant database design, do you think it is sufficient to include the tenant id only in top-level resources, knowing that child resources will always be parent-scoped, or should every table include tenant_id as a foreign key? For example, if Tenants have Projects that have Tasks, is it enough to specify Pr...
I've been trying to mull over a question I am not sure how to solve and it probably has a simple solution however I am trying to work out a simple solution. The following scenario is as such. Let's say we have the following variables. string username; string password; string domain; string location; and I want to run ...
We are developing a SaaS product with which we want to give our customers the ability to produce “real time” (i.e. users should be able to get response within seconds) reports. The “raw” (i.e. not specifically materialized for reporting) data is in MongoDB and our front-end clients may be native mobile and Web. The que...
Scenario: Stack: Java, Spring, Hibernate. Model: Client-Server Application. Pattern: Model-View-Controller (MVC). The Service Layer classes has three behaviors: Some services have the business rule within the methods and delegate the persistence to the application. Like: EntityManager.save(entity); Some services si...
I've been developing applications according to the principles of DDD for a while now, and, as many, I often run into issues when it comes to persisting an aggregate. One of the main advantages of DDD is that it allows me to use the full power of OO design in my domain -- as such I want to use polymorphism and conform t...
I'm trying to adapt an algorithm to calculate covariance to work over a rolling window on the data. Wikipedia has an algorithm for online covariance: def online_covariance(data1, data2): mean1 = mean2 = 0 M12 = 0 for x, y in zip(data1, data2): n += 1 delta1 = (x - mean1) / n mean1 +=...
An image "size" can mean both the widthxheight or its weight. How could I edit this paragraph to not use the word 'size' twice? Allowed sizes: 300x250, 300x100 Max size: 300KB
I need to generate simple, 4 digits confirmation SMS code, which based on given information, e. g. username, or birthdate, whatever. So, for two identical inputs, I need two same output codes. I can't store this code in database. I'm writing in C#, and have been thinking about GetHashCode method, but he is highly not r...
Consider the following boolean array where dark == true: In this scenario the probability that a cell is dark or light is 50/50, but this may not be true for the general case. Maximizing only on density we see that cells 12 to 16 (inclusive) have the largest area with 100% dark coverage. Using this binomial probabili...
Which caveats should I be aware while localizing numbers in my front-end application ? Example: In Brazilian Portuguese (pt-BR) we split thousands with dots and decimals with commas. In US English (en-US) that's the contrary. In pt-BR we present the digits separated by the thousands, the same as en-US. But reading abou...
I want to ensure that I understand the scenarios which CQRS is intended. For example, if a web service has two types of clients: many external clients who will only query via GET; they will never POST/PUT/PATCH/DELETE an internal client who will primarily populate (via POST/PATCH/PUT/DELETE) the data store that the se...
I'm low man on the totem pole (consultant) who was pulled into a project for a large organization. How do you explain that this large organization practices zero industry standards and follows no software patterns? Yet everyone seems completely happy and convinced that nothing is wrong. This is the least maintainable, ...
Angular2 is based on the Angular-CLI, correct? So When I run ng serve there is a machine spun up at localhost:4200. Now if I want to add a database, a lot of people end up packaging Node.JS along and we have: Node server @ 3000 [or whatever your choice] Angular Server @ 4200 MongoDB @ port 12701 To me this seems redu...
What's the proper handling for a part of a script that is a non usable TODO case? Should throw an exception, a false assertion, crash the script or something else? By non-usable I mean it is not implemented, so that part of the script just does nothing yet.
I try to have find solution to get away from these heavy problems of number comparisons in Java... at least for numbers in a certain range with a certain precision with certain representation error. The task is to implement an equality check for numbers that are implementing the Number-interface of the java.lang packag...
tl;dr: Should I avoid exposing third-party types in a public interface? I'm working on a Kotlin-based project that relies heavily on data keyed with two values. It's just something I'm tinkering with at the moment to learn Kotlin, but I've been considering publishing it to a public repository such as Maven Central. ...
Okay, I have a list of people in a database, can you point me to some sample coding that will show me a good algorithm to determine who the next person in line is? Because people can be added to the list in mid stream, so not sure how to always pick who is next. I've spent a lot of time trying to figure this out and I...
While reading through an answer to the question Clarification about Grammars , Lexers and Parsers, the answer stated that: [...] a BNF grammar contains all the rules you need for lexical analysis and parsing. This came across as somewhat odd to me because up until now, I'd always thought that a lexer was not based up...
I am a web developer who is planning to build a web application which requires user-generated input, with that input presented somewhat like a blog in the sense that there is an article with pictures, and a gallery, along with some special features which will require me to add custom html and js, with Google API integr...
In certain programming languages, the meaning of certain names may be fully determined at compile-time (i.e. without running the program). Example: A function in C has global scope; when the name of the function is used somewhere else in the program (and the variable is not shaded by another variable of the same name) ...
I have a documentation repository on github which submodules other project repositories. I want that everytime there is a change in any projectname/docs/*, it automatically be reflected in my documentation repository's submodules. Do I have to setup a jenkins job for this (git submodule update) or does submodule do th...
I use liquibase for source control of our database. I put there changes to the schema, static data and procedures. So far I've kept permissions out of it; we have just four users with very well defined permissions that don't change. Now, for a new application, I need to create a new user and grant it table and column-s...
I have been asked to do the following: Take a project within a repo (repo has multiple projects inside) Build ant build script that will build two separate tomcat webapp war files. They are two web apps. The two war files have to be different web app since there are functionalities required in one war file and must no...
A typical piece of code printing a number to the console is this: Console.WriteLine("The number is " + 1234.5 + "."); This contains English text and formats the number using the locale of the current user. This can result in mixed output (here, German): The number is 1234,5. The application is not localized. It's us...
Studying beginners course on hardware/software interface and operating systems, often come up the topic of if it would be better to replace some hardware parts with software and vice-versa. I can't make the connection.
What is the formal name for this specific problem scenario in an event-driven architecture, and what are the common approaches to handle it?: After an action or event is dispatched, several subscribers will execute in order. But after the first subscriber is executed, it triggers a new action which also has several sub...
I'm familiar with the Page Object Pattern from doing Selenium tests. It seems to me like the Angular 2 team has borrowed this concept in their testing documentation. But I feel like this is not precisely the same concept. In Selenium tests, the Page Object quite literally represents an entire HTML page. In the Angular ...
I'm working on an architecture document based on quality attributes. I'm trying to explain our search algorithm based on tags, historics and some bi information as a way of favouring a quality attribute. I read some material about this (Software Architecture in Practice, Third Edition) : usability is the closest I got...
I am writing a Python module that uses Numpy. I am trying to follow the Numpy docstring format. In many of my functions, the same parameters show up. It seems repetitive to explain what they are in more than one function from the same module. Is there a common practice when dealing with this?
Say you are writing an ORM like entity framework. You write basic POCO, and then let entity framework do the job of creating equivalent structures in the database according to those objects. This can get hard if those objects have foreign key relationships. Theoretically speaking we would need some sorting in order to...
We are aiming to reduce code noise that would be common for all Controllers such as basic CRUD. public interface IGenericController<T, Y> where T : BaseMaster { IEnumerable<T> Get(); T Get(Y code); HttpResponseMessage Post(T entity); T Put(T entity); T Delete(Y code); } this would be use as pu...
Instead of unintelligible names and acronyms for new products and services, is there any other way of naming software that could also say what it is and what it does? For example, instead of naming a software Abricudabrah or similar which typically means nothing and says nothing about what it does, could there be a nam...
The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time. — Tom Cargill, Bell Labs What does that exactly mean in practice? That programers do substantial amount of work and that they...
I have a ASP.NET MVC application and connects to the SQL Server running on a different server. I wish to know which is the default protocol used between the MVC app and SQL-server to exchange the data.
In my organisation people regularly have 3K+ emails in their inbox. They're swamped and non-important email is ignored and lost. (Think big Corporation). Email ceases to be a useful medium in this environment. For a while on our CI Server (eg Jenkins) we ran builds that you could view the status of on the Jenkins site...
Using Semantic Versioning, I have a product that is version 1.0.0. It has a configuration file entry shipped with the product that specifies an operation timeout value: myTimeout=1000 I need to change this configuration value. Is this a MINOR or PATCH increment? It's not a bug fix, but it's not really introducing a ne...
I was wondering how you handle issues like that in your company. Usually when something goes wrong at a customer he needs to: Submit the issue he encountered Add logs / configuration data Suddenly the logs are not in high debug level - so he needs to increase debug level and reproduce the problem Then again, you can't...
Today we found out the cause of a nasty bug that only happened intermittently on certain platforms. Boiled down, our code looked like this: class Foo { map<string,string> m; void A(const string& key) { m.erase(key); cout << "Erased: " << key; // oops } void B() { while (!m.empty()) { auto to...
How important is a documentation? or a spec for that matter? I've been writing software professionally now for about 5 years. Each new job I start I am more often than not faced with spending a few days reading the code trying to figure out how everything works, taking notes, and eventually producing the documentation ...
Our organization currently has several web applications running on lamp servers. They are mostly static content, but also include php via codeigniter / laravel / vanilla php. Whenever we make changes to any of the files we will update a git repository on a separate server to track that change. However, we also have con...
I am a student working on a mvc project to move a site from coldfusion to .net mvc. Were are also redesigning the site in the process so I am working with other team members, the design team members have a basic understanding of razor, but aren't expected to know any other parts of the framework. I've always tried to u...
I have a class called class object which have variable called density (_OMEGA is related to density : density = _OMEGA*x). I also have configuration file(a txt file) where I say _OMEGA = 1.4. Then I read that _OMEGA and other configuration variable from the txt file into a container in class config which I will be usin...
I have two options for implementing caching in my web application. I can either add a Varnish cache outside of my application code, and cache the responses on a per-request URL basis, or I can use an in-memory cache like memcached to store the results of database accesses. I am having a hard time choosing between these...
I'm writing a Matrix type, and I would like the following code to define a 2,2 integer matrix, put its first element at 3, and throw an exception upon reaching the third line: Matrix<int> a(2,2); a[0][0] = 3; int b = a[10][28]; For this, I need to overload "operator[][]". Let me explain further: My matrix is define...
The using directive gives us access to types without using their fully-qualified names: using MyNamespace.Foo.Bar; The using statement acts as syntactic sugar for try/finally blocks which ensure that objects are disposed of properly: using(var x = new MyDisposableClass()) { ... } These two situations seem to have not...
I develop (mainly UWP apps for personal enjoyment atm) on a x64 laptop, but in Visual Studio I have been blindly using the default x86 solution platform. Should I be using x64 or x86? (so ashamed to even be asking) There's a few previous questions that touch on the subject and mention differences at a high level but t...
At work we have a quite complicated system. Let's call this system, System_A. Our QA team has created another system, call this system, System_B, to test System_A. The way System_B is used is as follows. We generate inputs (using System_B itself), IN, process such inputs back through System_B and generate outputs, O_B...
Suppose I am using ionic2 to create hybrid apps, and it is common that I can finish a job by either using features of ionic2+angular or just html+ javascript+css only, for example, click to disable a button: html+ javascript+css only solution: <div id="myDiv" onclick="( function(){ document.getElementById('myDiv...
I've been reading the top posts of stackoverflow and SE and all over the place it says how bad singletons are but I am unsure how to rewrite my code. As of now I have two projects that bind into a gameEngine that each have a singleton class to access the content: Singleton for retrieving/creating an instance of a 3d s...
I've been following the quick tutorial on using Castle Windsor in MVVM WPF: TUTORIAL I've set everything up (as for the basics) but I came to the point of creating a new Window after a button click. This is where I got lost. Basically, from what I learned, the container should NOT be referenced more than once. public c...
Hypothetically, if you (I / someone) were to create a multi-threaded application, utilising the processing powers of multiple cores (for example, using TPL in C#). Would that program crash, if it were run on a computer with a single core? Or rather, would the application move to context switching / time-slicing?
Programming against interfaces is an often-heard good practice in software development. Together with extension methods, this provides a great functionality. However, in C#, there are limitations to that. Let's declare a simple interface for a 3D-Point: public interface IPoint3D { double X { get; } double Y { get; ...
I have joined a new workplace where they follow Agile (Scrum). There are several products, each has an internal product owner, but the development team is an external vendor (developers and scrum master). As a scrum master, i see this is a slightly different situation from Scrum Classic, where you have all your resourc...
TL;DR is val name <- more readable than name val <-? I'm designing a semi-concatenative, postfix language. I haven't given much thought to the style in which variable are assigned, and now I see that there are two (main) ways to do it. Originally, a variable assignment looks like: variable value <- So, here's an examp...
In Android, I rather frequently need to get results from more than one service that utilizes an asynchronous callback pattern and I want to know if there's a better way to handle this pattern than what I'm doing. Right now the way I handle it goes something like this: I call both services and pass them my callbacks. In...
I'm writing a handler for download/import of data. After inserting data to the database, several import jobs can be called, but usually it is just one. So there are two methods to get the import job(s), that can be overridden from the abstract base class, one being abstract, the other one using the first one. Please ha...
I am developing data analytics algorithms that are supposed to process large amounts of data. Thus I am aiming to develop my mathematics already in such a way that it is possible to distribute the algorithm later on many machines (Big Data). I am able to develop my algorithms in such ways that it calculates some inte...
I was reading the Go-lang documents and found under the section of Types that Go has no type hierarchy. What does that mean exactly? Is it like python that types are been checked at run time (dynamically typed) rather than 'compile time' (statically typed)?
I know that long time ago computer scientists decided to treat all pointers to memory cell of address 0 as NULL. However, the memory cell at that address does exists after all, right? In that case, what value is stored there? Since it's OS that decides how to allocate memory it should be able to access (and modify) val...
In Lua, I can create an object like so: local foo = Foo.new({10, 10}, 3, right) or like so: local foo = Foo.new({ pos = {10, 10}, len = 3, direction = "right" }) The former is more compact, whereas the latter is more understandable and flexible. Which is generally considered the better form of accepting a...
Is there any adequate reason for a manager to forbid the use of Git GUI Clients in a developer team. I was talking to a friend about - let's call Foo Git GUI Client - all the features and how i was able to speed up some tasks and he said that any client is forbidden by the managers in his company. Question is: Why? A c...
I'm not quite sure of the proper flowchart notation for returning an object/value from a function (I'm also looking for some quick tips on proper flowcharting notation in general, if anyone notices any glaring issues). Key key = FindKey(); Ferrari f355 = Valet.GetCar(key); f355.Go();
I am building a service that will push notifications to many other services. It has a couple of different notification types that each consumer may care about, but likely will not care about all of them. Instead of requiring many different endpoints, I am thinking of making a single endpoint that has a notificationType...
During code review, a minor suggestion was presented that some implicit behavior be made explicit. The reviewer had skimmed over the code in question, became confused after mistakenly interpreting the code's purpose, and only discovered the cause after some careful analysis. Below are the implicit practice and suggeste...
So much of the benefits around Event Sourcing apply to the being able to audit the system and show an aggregate's state throughout its life. However, I haven't been able to find any examples of where to record who issued the command and when with was issued. I have been doing a lot of my learning by dissecting the CQRS...
I'm trying to debug my MCTS implementation for TicTacToe (it doesn't block obvious wins for the opponent). I was wondering what the algorithm should do if it expands to a node which is a game over state. Should it continue to "simulate" that node and back-propogate the results up the tree or just ignore it if the node ...
Our team has just started using JIRA. Now we are looking for advice on how to build our process in the most convenient way. We have stories to be implemented in further sprints as well as bugs to be fixed. The question is how should we approach those bugs. I see following options: Assign bug to a developer Create new ...
I've written some apps using simple imperative way - now I want to learn more about building software the object oriented way. My goal is to take an Excel file and load one of the tables into memory. I can do this by: Creating a list of strings for each row, and store the table in list Creating a structure/ class for ...
I am making a desktop based financial app in Ruby On Rails for my friend. I have a little concern over the system time I am using since time log being very important. What if system time changes because of some hardware issues. Should I go for time from internet or what are the alternates for this issue?