instruction
stringlengths
34
36.1k
I have to design a Class for ATM cards with the following attributes: Cardholder Name Card Number Pin Other than getters and setters, I have a method to validate the pin of the ATM. As per the principle of encapsulation all the methods related to the ATM should be part of the ATM class. But in case, later we need to...
Let's say i have a table (in a large enterprise application) that has about 10 columns. I am limiting any consumer access to the table to only be possible by calling stored procedures. When it comes to updating a record in the table, i basically have 2 options. One stored procedure to update all the columns of the tab...
Right now I'm using Direct Exchanges (i.e. one queue per "topic", pretty much pushing messages directly to a queue). This works OK, but I'd like the flexibility of working with Topic Exchanges, specifically multiple consumers subscribing to topics without destroying the message (i.e. multiple queues per topic). The com...
I'm working on a free proyect over Github. I fork it, made some changes, did a PR and everything worked ok (PR was accepted). Then I update my fork with upstream, did some other changes, and made another PR. Then I realice that my PR included all the commits I pushed earlier, and every file I modify, even the ones I al...
We are developing a system with coarse microservice architecture. We have an API that uses controllers and back-end logic with Entity-Framework repository, and several types of clients that use this API, all in dotnet, therefore, typesafe. We need to use some sort of data transfer objects for communication between the...
For example, suppose my app have some localization texts. My question is, should I load appropriate locale at start: var locale=userPrefs.getLocale(); localeStringMap=getLocaleTextFromFile("locale_string_"+locale+".json"); //some other code //. //. //. var message=localeStringMap["welcome_to_use_the_app"]; or get th...
Google describes the rules for Firebase as: You are required to notify your App Users by disclosing the following information: The Google Analytics for Firebase features you have implemented. How you and third-party vendors use first-party cookies, or other first-party identifiers, and third-party cookies and simi...
I develop a WPF application using MVVM and I am learning how to do things best. I have a WPF form with selectors, two list with search fields, and some other elements. Currently all is in one form and it works. But by now the VM for that form has more than 800 lines and it is not yet finished. I want to structure this...
Our application creates audit trails in response to system actions and user actions. Our business logic depends on these audit trails to find out which user performed what action. Is it good practice to have business logic use audit trail data?
I have function that takes as arguments a number of classes of average complexity. When writing docstring for that function, I'm running into a series of questions: Should I describe (besides what the function is doing) those classes too, or can I assume that the reader will dig up the class definition? Or should I po...
I'm working on a system with hard real-time constraints in c++ and I need a very fast way to calculate the rolling/moving/streaming median of a set of numbers of size N=100 to 300. Normally this size would be trivial but in this case the algorithm will run about 1000/2000 times per 0.1ms Every calculation a single valu...
I found this question Return magic value, throw exception or return false on failure?, however it is kind of broad. I would like a more specific answer. Say I have a method called Connect() which connects to a remote device over an Ethernet socket. If the socket fails it throws SocketException. So the way I see it I h...
I'm designing a REST API that needs to allow me to send messages to members in the system. Right now, I'm thinking about creating a /messages endpoint that I make a POST request to when I want to send a message, providing a member's ID and the message content. The problem that I see with this approach is handling the c...
What name should I give classes which are just for configuration? For example, when using JAX-RS, every application is required to have an Application class which extends the superclass javax.ws.rs.Application like so. The Application class is just to register the list of resource classes. public class APPLICATION_NAME...
I've been writing web applications for almost 10 years. The ASP.net stack has been my bread and butter and although it has a lot of great things about it, I honestly never chose ASP.net. It's just a matter of what my employers and clients wanted. Recently, I had the opportunity to prototype something I was working on...
I do a lot of work in various languages, most of which are scripting languages such as JavaScript, Shell Scripting, PHP and so on. But I do also work a lot with Java, which is closer to a more "real" language. C/C++ has been an interest always, but have not had much use for it. I did have a few small things in some Ja...
I am very new to Domain-Driven Design. I have come across a part of a domain which I'm not sure if I have modeled in the best way possible. There is a Membership entity which has a membership type. public enum MembershipType { TypeA, TypeB, TypeC, TypeD, } Each Membership can have 1 or some Businesses...
Given that a lot of modern web applications just consume JSON data from the sever, what is the point in having a REST api at all instead of just using SQL's query language? Nowadays people are starting to use GraphQL. From what I understand is a query language from the client to the sever, which then gets translated i...
Today, I searched for includeOS and I found that it defines itself as a minimal unikernel. I am wondering what is UniKernel. The wikipedia explanations are not clear enough to me. Is unikernel an operating system incorporated with a single application for a special purpose similar to embedded systems?
If data structures such as trees and certain sorts(quick sort, merge sort) work using recursive algorithms and recursive algorithms take up a lot of memory space in the stack and can only work on a limited data sets(if not it'll lead to stackoverflow), then how come trees and the aforementioned sorts used practically t...
I am working on the domain model of an application that stores information provided by sellers about the goods they sell on a platform. The application just acts as a data store for this information. The information is called as an "ProductFact", and may be diverse. Each example below represents one "ProductFact" insta...
At the end of this article from Martin Fowler there is this sentence: In general, the more behavior you find in the services, the more likely you are to be robbing yourself of the benefits of a domain model. If all your logic is in services, you've robbed yourself blind. What the whole, very abstract article, doesn't...
I have a class, which looks like this: public class Customer { private readonly IList<Order> _orders = new List<Order>(); public FirstName FirstName { get; set; } public LastName LastName { get; set; } public Province Province { get; set; } public IEnumerable<Order> Orders { get { fore...
I don't have more than 6 months of experience and I am a little lazy . I work on Android platform . I have very good skills in understanding what is happening in general . The problem is that I don't have the experience to read and understand someone elses code (btw I just got a new project which I will develop a new f...
Currently I have an entity called Product with the respective ProductRepository and ProductService. For ProductService, I have tests for: Read (Covering Create too) Update Delete Besides achieving higher test coverage, is there any particular reason to also test ProductRepository? What I think: It could be possible t...
I am learning about SOLID principles in a Pluralsight course where Command Query Separation is being discussed. I am fine with the query functions returning something (and crucially being non-mutating). The question I have is about commands. The idea here is that commands should return void. What if there is a problem ...
I have been using git for a while now primarily on CLi. I am the only person working on this project so far. I just have 1 master branch and 1 production branch. The production branch is named such that all tests in that branch pass. I work directly on the master branch. I had a issue recently, which prompted me to thi...
From what I can tell from Scala and Hack- Mixins: Can have state (ie. instance properties) Can only provide concrete methods Can have constructors, that are called in the same order that their classes were mixed in If A mixes in B and C, A instanceof B == false and A instanceof C == false Traits: Can only provide me...
I have many substrings(2-5 words each) which I would like to search in some text of about 40-50 words length. What is the most efficient way to flag matching substrings. Currently I am simply using: for substring in substrings: if substring in fullText: return True substrings - the list of strings to be searc...
I'm creating audit tables to track changes made to some of my crucial tables and I'm wondering whether there's a point to history rows having their own id. Here's how my interfaces look like: public interface ITrackedDbEntity : IDbEntity { Guid GUID { get; } //pk, unique int Id { get; set; } //unique, not pk ...
I am just designing my application and I am not sure if I understand SOLID and OOP correctly. Classes should do 1 thing and do it well but from the other hand they should represent real objects we work with. In my case I do a feature extraction on a dataset and then I do a machine learning analysis. I assume that I co...
I have a class called Book with fields such as title, type etc. I also have a class called Library that manages books. Library has methods that: Add a copy of a book on a shelf Move a copy of a book from a shelf to another How Can I manage the fact of the copy of the book? One solution is create a subclass of Book,...
I'm trying to improve my skills in planning out clean, modular projects with minimal coupling. Is it best to keep objects as generic as possible? If so, are there any pitfalls I should try and avoid when designing architecture?
Note that I cannot use static inheritance due to language limitations (Java). There is a general Building class. Each instance of Building has properties that exist regardless of instance variables (such as width, length, max level, BASE damage). There are numerous types of buildings, such as resource and defensive, an...
I am looking to create a random username based on a set of existing phrases plus an integer since there can be multiple users with the same phrase. For now lets assume there's 12 phrases such as AnonymousPotato, so a user who signs up could randomly receive AnonymousPotato12345 as a unique username. The user would be s...
I am writing some code that really smells but I can't figure out exactly why. I have documents that exist in multiple languages. I want to be able to serve a document in its requested language and be able to switch it out for other languages when requested. On my database the documents are separate entries with identic...
As far as I know both the regular and enterprise developer programs both have a 100 iPhone limit for development. I don't mean distributing the app for testing where the limit is higher, but for plugging the phone in for debugging with Xcode. How do larger companies deal with this limit? If they have multiple teams tha...
I've written a few things using .NET Core and like it a lot. So far, I have always used Visual Studio Code (which I think is very good and getting better all the time) and have enjoyed being able to pick up work on a Mac. I've been using Visual Studio less and less as I do more using .NET Core. However, last night, I a...
I would like know opinions about the next sentence: "In a object oriented static typed language you should declare variables and parameters as broad as possible and return types as narrow as possible" In some extreme this afirmation could produce this code: interface anyInterface<T> { Collection<T> getCollection()...
Are there objective, supportable software-engineering arguments for or against modifying the values of by-value parameters in the body of a function? A recurring spat (mostly in good fun) on my team is whether or not parameters passed by value should be modified. A couple members of the team are adamant that parameters...
In refactoring some code I found a helper method get_records_from_file that has a complex return signature: class RecordDefinition: def __init__(self): self.foo = None self.bar = None def get_records_from_file(file_name) -> Dict[int, List[Dict[str, RecordDefinition]]]: ... After some inspection I...
Here is a diagram of how our source control setup is configured. The issue with this setup is how we handle various customers. I would really like to use a different approach than copying the entire baseline for each of our customers. I think further down the road this will become a major problem to maintain. How can ...
Assuming I have the following (over-simplified) class structure: class Base { public: Base(int valueForFoo) : foo(valueForFoo) { }; virtual ~Base() = 0; int doThings() { return foo; }; int doOtherThings() { return 42; }; protected: int foo; } class BarDerived : public Base { public: BarD...
We are using version in following format: Major.Minor.Bugfix.Test Development for upcoming release is going on in the trunk. When enough features are done we are creating a new release branch: 1.1, 1.2 and so on. After branch is created there is a continuous "stabilizing" process, producing test versions of branches:...
We have some fields (age, visit type, insurance type, city) and some rules: Some doctors that define weekly schedule template like as: Doctor D1 works on Monday 7-9 pm , Thursday 7-9 pm. Some type of Visit Type like as: Doctor D1 accept Follow up- Laser- Rhinoplasty. Some type of counters rule in specific time r...
I'm midway through Eric Evans' DDD book but don't think this question would be answered in the book. If an application has its own complicated concepts different from the underlying domain, can we create another domain model for representing the application too? An example would make it clear. Say, the core domain of a...
The "Three Questions" for Scrum dailies sound to me like a perfect instruction, to waste 15 minutes with useless status reporting: What have you completed since the last meeting? What do you plan to complete by the next meeting? (impediments...) It often goes in the way of: "Yesterday I did task X, today I will work...
I'm having troubles with using the right workflow with TDD. Some people say we should design before writing any code, some say we should make a test, make it pass, then refactor the code and that should help our thinking to find the right design. But everyone say you should have 10 times more unit tests than integrati...
We had a contractor visit recently who questioned our methodology of structuring projects. Please note that I am specifically referring to the directory structure. He suggested using the Microsoft guidelines. I thought I would be able to Google "Microsoft guidelines .NET project directory structure" and find somethi...
The date format should support different timezone and Daylight saving issues.
For a match I have certain number of players, certain number of groups (players and groups are aliquot) and certain number of rounds to be played (players are reshuffled every round). Ideally, I'd like players to meet new people every round. It seems like a common problem that had to be solved many times before, If I o...
I had a recent code review that gave me some slightly surprising feedback. It was in an instantiable service class that had a number of fully encapsulated private methods. In other words, methods that didn't reference any higher level functions or variables. For a trivial example: private decimal IncreaseByPercent(deci...
I have a CQRS system in development that passes the Command to a CommandHandler, which gets an Aggregate from a Repository, and calls a method with the properties of the Command (converted to ValueObjects). The method then creates the Event internally and registers it in a hash object to be collected and persisted late...
i’d like to push discussion on the same named thread again. I also use auto increment primary keys as foreign keys - mostly for code tables. Every row also has a code for identifying entries for users (like ProductKey). Everything works fine till I need a validity period for entries in code tables. e.g. every Client ha...
I have a library with several layers. The library is a hardware API and has several threads. The application that is using it has no direct user interaction the UI is for display only. I needed a way to tell the user if there was an error and what it was. So I created an Error Event that passes a message up the layers....
To clarify, as I'm not entirely sure how to summarise in the title. I have a redis cluster and a redis-backed scheduler (similar to sidekiq/resque, etc). My redis cluster has a master and a couple of slaves. I insert a job onto the master and that is replicated onto the slaves. I have 4 workers listening on these slave...
As I was working on upgrading deprecated ereg_replace() statements in an e-cart sollution I was suddenly puzzled by questions regarding how to handle the submitted data I was working with. I was working with the add to card function, which from the backend perspective recieves an integer for how many products to add to...
Suppose I am designing a web application and also building a Web API with authentication via Kerberos/NTLM. The Web API is first for my app, but I imagine I want to make it general-purpose. My instinct is to create the Web API as its own separate solution, and then consume it with XHR requests in my web app. So perh...
I'm writing what I might refer to as a Maven project dependency management process for a project I work on. Whenever a developer wants or needs to change the version number of an existing Maven dependency or add one or more new dependencies, they must follow the process. So far, I've identified four stages: Confirmati...
Suppose that you are in the phase of requirement elicitation (discovery). You have already interviewed your customers and created use case models to discover as many requirements as you can. However, you strongly suspect that there are some implicit requirements (e.g., domain knowledge that is so familiar to cus...
So I've done a good job separating the DAL from the BLL. I use repositories for each aggregate root. The issue I'm having is database concurrency with IDs in the domain. I don't want to use the surrogate key in the domain layer (e.g. GUID). So the aggregate root I have now is a Journal and that Journal has a list of...
I have a great deal of 'dirty' data pulled from an API request. Before database insertion, I clean out a lot of line feeds and regex out values such as height and width from item descriptions. This is my first large project as a software engineer, and I would like to leave something coherent for future developers. He...
I have two parallel hierarchies: B and C implement interface A D and E extend the abstract class F I want to be able to do: F f = createObject(A a) where createObject should follow the behaviour: F f createObject(A a){ if (a instanceof B) return new D(a) else if (a instanceof C) return new E(a)...
I'm working on a project with a MVP architecture. My program revolve around forms that give rights to people. There are X differents forms depending on profiles ( so there are X differents profiles) I have an abstract class which we will call BasicFormClass. Each forms has a presentation that inherits from BasicFormCla...
I'm in the middle of refactoring a project (in C++11) and I'm struggling with a decision is it good to change huge enum with about 100 record to separate classes. This enum is used in about 4 places in code in 4 different functions with huge switch statements. For every enum, the record is some code in every function. ...
I'm testing that a function does what expected on a list. So I want to test f(null) -> null f(empty) -> empty f(list with one element) -> list with one element f(list with 2+ elements) -> list with the same number of elements, doing what expected In order to do so, What is the best approach? Testing all the cases in ...
Going through Effective Java, Joshua Bloch states that the drawback of using JavaBeans pattern is that an object may be in an inconsistent state partway through the construction and with JavaBeans pattern, we cannot make our class immutable. I have understood this much. He also says that we can reduce these drawbacks b...
Where I work, we use a language for our desktop software development (Delphi) and an other for web apps (asp.net/c#). My bosses want me to implement a feature on a website but they ask me to develop it in Delphi because they think they might need it for one of our software someday. When the same situation happened in ...
I do not have production experience with docker and have several questions regarding a local registry: A dockerfile is the description (=recipe) of how an image is built(=cooked, e.g. FROM alpine:3.5) If the image on my Docker Host isn't present, it is pulled from a docker registry. As far as I know is Dockerhub regar...
In my understanding, evolutionary architecture boils down to making architecture easy to modify. Now architecture is often defined as the things that you should get right early because they will be hard to change later. How does this fit together? Is there any difference between evolutionary architecture and simply min...
Note: I am note sure how to phrase the title This is pseudo code of my Project that I am working on. For conciseness I have left out some details. I have a 2 types of Consumer classes. One is inherited from the other and does a some extra things. Consumer has a thread that runs a queue of tasks. I have a IProducer that...
Assume You have some POJO Animal like public class Animal { // some fields } You have some enum AnimalType like public enum AnimalType { // some animal types } You have some method that given an Animal returns an AnimalType with signature public AnimalType getAnimalType(Animal animal); Finally, you have some inf...
I have seen it done both ways, but I have never seen any discussion around which is the more "right" way. Say you have a entity that has children relationships to other entities. The children can't exist without the parent, so does it make more sense to make on service that handles the CRUD of the parent AND the child...
So, there is a workflow I feel needs to exist. It may already exist, and I don't know about it. Consider the Linux command line workflow, the "motto" of Linux, more or less. You have a bunch of small programs, accepting input and producing output. Each does one thing well, and the user puts them together to do compl...
I have a code base that contains several different instances of the following pattern, the key point of which is that the concrete type of the class is decided at run time based on a string from a config file. class Foo { public: virtual void bar() = 0; }; class AFoo : Foo { public: void bar() { // ......
So one thing I didn't really think about when designing this personal finance application was WHEN (not HOW) to persist the data. I'm using DDD, a 4-tier architecture, and EF. It struck me when I added a new Transaction, Account, etc. that it's immediately saved to the DB. However, this is not how most desktop applic...
This isn't so much as a specific code review, but a concept review when converting a class diagram to code and then eventually a database, in Python. I know how to add things in to a database, but I have only ever done this directly with SQL from forms and not from classes, (which I believe is called ORM) I have the fo...
In our user-rights management system we basically follow "CRUD", where at each incoming request the user is checked against his rights, and see if he has create, read update or destroy rights for the data he wishes to access. This system is created by my predecessor, however I'm constantly in doubt if this is the right...
We've built a class that allows you to easily draw stuff on a <canvas> element. That class is called Canvas. I've encapsulated the <canvas> element and the class itself in a WebComponent, called <paper-canvas>. <paper-canvas> <canvas id="#canvas"></canvas> <paper-canvas> <script> class PaperCanvas { constructo...
I've recently caught an odd behaviour in my own coding: At some point in the last year I began creating protected static methods to implement the logic of my public methods, ensuring that the protected static version contains all of the logic, but is not affected by state. e.g. class Demo { string someAttribute; ...
I am writing automated test cases in Visual Studio 2017 test frame work. I am testing the ‘create user’ part of a web API. A user needs to be created with a unique email address. Once a user is created they cannot be deleted. Is there way to write automated (run on check-in) test cases, that need unique input data for...
I am trying to understand behind the curtain scenes of Javascript and kind of stuck in understanding the creation of built in objects, specially Object and Function and the relation between them. When I read that all the built in objects like Array, String etc are extension (inherited) from Object I assumed that Object...
A common pattern in database design is to append dynamic columns to a table with a design like so: create table MasterTable ( Id int not null primary key , Name nvarchar(64) not null unique , SomeColumn2 int not null ) create table MasterTableAdditionalColumn ( Id int not null primary key , Colum...
Where I work we've got wallets with transactions (i.e. every transaction belongs to a single wallet). Currently we're working on an addition of transfers between wallets. As a part of this, a new Transfer concept has been added to the ubiquitous language dictionary. One functional requirement is to give users the optio...
I see questions similar to this with regards to parameter names that match properties on the class, but I can't find anything regarding using a parameter name that is the same as the parameter type name except for casing in C#. It doesn't seem to be a violation that I can find, but is it considered bad practice? For ex...
My question regards the best practice / industry standards to prevent rogue users/admins from directly logging into the database console and updating sensitive information such as financial info / balances, etc as opposed to using the software which would otherwise validate the user's actions. I ask this because the so...
My application consist of a web client (implemented in angular or reach) and rest web service, both hosted on different servers. For implementing the OAuth2.0 login for Google, Facebook etc., should i implement the same on client side or server side and why?
Maybe anti-pattern is a better word for this question. I do not know, but I mean a violation of DRY. Id like to reuse a partial view, and I can, but that partial view has other things in it I don't want in my div I'm populating. For example, I have a page with a name. I can browse to a view and it shows me informati...
I have a system i've written on paper and am trying to write this into C# in a easy to use manner. I want a series of connected waypoints (where by waypoints can be connected to any number of other waypoints). But waypoints can either just be an arbritrary point along the path or an actual object in the system with som...
I have a loader class that executes data loading functions at boot-time for my application to give me test data. The idea is pretty simple, I'm reading in XML data, using JaxB to turn it into a POJO and then persisting the POJO using JPA repo. Here is my code (pretty small): Looking at the parseFile method, I create a...
I have a project that is sufficiently large in size that I can't keep every aspect in my head any more. I'm dealing with a number of classes and functions in it, and I'm passing data around. With time I noticed that I kept getting errors, because I forgot what precise form the data has to have when I pass it to differe...
I was hoping to get some advice from you folks on my table design methodologies (specifically in MS SQL if that matters). Let me start by showing a couple of example tables that I might have in a typical application: EntityType ----------- EntityTypeID int identity (PK) Token varchar(10) (Nonclustered IDX, UNIQUE const...
To keep classes decoupled I'm using the Mediator Pattern like so: class Mediator { constructor(canvas, selectionBox, undoManager) { this.canvas = canvas this.selectionBox = selectionBox this.undoManager = undoManager } addText(text) { this.canvas.addText(text) this.undoManager.captureUndo() ...
I am implementing a custom ILogger (interface for logging). I have succesfully developed implementations of it with some famous loggers like Serilog or Log4Net. Now I want to create a memory logger that stores all the logs inside a List (memory). Since the List will only exist in the MemoryLogger:ILogger , I think th...
We have a bunch of services which are using AWS Kinesis to communicate via events. We have different events such as MasterDataUpdatedEvent, PriceUpdatedEvent or AvailabilityChangedEvent. Currently, we are using a dedicated stream per event: MasterDataUpdatedEvents go to master-data-updated-event-stream PriceUpdatedEve...
I'm only a student, so forgive me if my understanding is poor or my ideas poorly expressed. I want to create a purely client-side browser application that works with the user's Dropbox account. They would go to the page, click 'Connect My Dropbox', grant permission, get the access token back, and store it in local stor...
I'm trying to determine the best application and database architecture for a project I am working on. The idea is that there will be multiple, separate applications that will all share a few tables like a User and an Employee table. Each Application will have a web portion (which may require an API, depending if server...
For the purpose of writing a library, I found to be nice to add types to some well known namespace. Example: I've written a couple of extension methods for BinaryWriter and naturally put them in System.IO namespace. Pros: they're readily visible and usable I do not end up rewriting it and shortly after discover it was...
I'm on a new CRM dev team. And simply put, I haven't seen sprint execution such a mess in my whole professional career. I have a deployment plan moving forward. I have an idea how I want continuous testing done in our test environment. However, I am torn on how often to push to test; because some sprints have alot of...
Suppose I have created an application that makes remote connections and does stuff, how does an anti-virus/anti-malware program decide if my app is harmful? I know there is a signature they check for to identify a program as either good or bad but it seems to me that would result in a lot of false positives because a l...