instruction
stringlengths
34
36.1k
I am building a web application which is meant to help display prices of products. The web-app is centered around showing prices in a custom bar chart. I am thinking it should be composed of a Model View Controller architecture. I am looking for input on my design plan, there is more than one question here. The model w...
I'm a quite a junior programmer, but happy to learn! :) I put together a WebApi based application and I sent it to be reviewed by my colleague. I got it back with the opinion the way I use partial classes hide controller complexity and size. I'm really happy to hear his opinion (he has been a developer for more that 15...
I am wondering because if it is, why does Entity Framework not offer logic to create a new object with the same properties to transfer data between layers? I use the entity objects that I generate with the entity framework.
Context: I'm working on a Windows console version of the board game Sorry. In Sorry, each player has four pawns. Based on drawn cards, a player moves their pawns around the board. These moves can impact other players' pawns, like bumping another player's pawn back to Start. Problem: Along with human players, I want to ...
I am trying to understand the difference between these two terms. In some contexts that these two terms have been used interchangeably. What is the exact difference between these two terms ?
Inspiration here Let's say I have a big, wonderful set of integration tests for my product. It tests anything and everything that we need to test. And after the product passes all these tests, we take a look at the source, decide it's complete garbage, and start from scratch. Is this a good business decision? I full...
I have read about authentications and become confusing about types classification. Let's start from Cookie-based authentication, If I understand it right, the key point is that all data, needed for user authentication, is stored in cookies. And this is my first confusion: in cookies we may store session id and so it...
After years of cowboy coding, I decided to pick up a book on how to write good quality code. I'm reading Clean Code by Robert Cecil Martin. In chapter 3 (functions) there is a section on dyadic functions. Here is an excerpt from the book. Even obvious dyadic functions like assertEquals(expected, actual) are problemati...
I have an application that manage absence of students. I asked everyone who will use the application (teachers , administration ...) about their needs and feature they want to see in the application. Now I don't know what steps I should follow before creating the software? should I draw a sequence diagram & use case ...
I am developing a project that uses the Electron framework which is released under the MIT license, but my question is not necessarily restricted to this one case: If an open source project comes with a license file, it is my understanding that I have to include this license file as well under most open source licenses...
I have an upcoming interview for a position at a company that deals with multi-petabyte scale data volumes. They're going to grill me about standard database design questions, but what are the best things to focus my revision/prep work on? How does database design change when you get to really gigantic scales? I curren...
My question is at a high risk of being a duplicated one, but that is not for lack of investigation. I've been around with this issue for long, and found nothing to solve it, but it seems such an obvious and common problem, that somebody must have answered this already. The thing is, i have two related tables, say produ...
I have to load certain object from the DB, and propagate it through few state and save after each state propagation. Let us illustrate this with the example of an Order entity. I now have to load few pending orders from DB and Cancel them based on few criteria. If these criteria don't match I should not cancel them. I ...
I've created a website for a tennis league. The two main pages are standings and schedule. When a user accesses the site, I'd like to have them select the league and season first. For example, the site could host standings/schedules for multiple leagues. So the user could select league ABC and season Fall 2016. For eac...
Our client has a software, where tickets come in. Multiple employees are responsible for answering these tickets (via phone), in a short amount of time (call back within X minutes). What would be the simplest way of preventing 2 employees calling back the same client / working on the same ticket? The client suggested, ...
In my code, sometimes there's a long function, to avoid messed up the local variables, i would use a pair of braces to embrace the details so the local variables will not be visible to the rest of the code, e.g.: bool pricing_deals() { //prepare deal type lookup table vector<DealType> deal_types; // deal type looku...
When I first played with a NoSQL database I become aware of the impact of UUIDs in a distributed system. MongoDB defaults to ObjectIDs, but I've always questioned in which cases UUID (RFC4122) would be a better choice. I found out that ObjectIDs are great. Not only they are smaller than UUIDs saving disk space, but the...
I wrote a FillSomeData(ParameterData param, Result res) method, which populates res with some data (just like it says on the label). Result is a class, not a struct, so FillSomeData actually affects res. Following a code review, my colleagues insist that I add a ref to the method signature (changing it to FillSomeData(...
I'm developing my first application using DDD and event sourcing. From what I understand, aggregate encapsulates specific domain functionality with one or more associated invariants. The invariants are translated into consistency constraints - at any point in time the state of the aggregate must be consistent (invarian...
I often create programs both for myself and others using various object-oriented programming languages. When doing so, they are usually relatively small (a few thousand lines at most). Recently, however, I have been attempting to get into making larger projects, such as complete game engines. When doing so, I often see...
I am relatively new to microservice architecture and I was never before involved in a project where the architect insists on having a circular dependency between services. I am in a position without a choice to design two microservices with circular dependency. Is my natural reaction against to do so - a real one, or I...
I'm currently writing an audio application using WASAPI, which is a really great learning experience, however I have this odd problem, I don't really know what to do about all these HRESULT codes in a good way and im looking for alternatives to my current approach which is if_else chains. Since the MSDN documentation m...
What is the major benefit of having pure POCO models? I get that Models should be clean and simple, but I tend to like to keep the maintenance of child objects within the model classes. For example if I have a ClassA and ClassB defined as follows: public class ClassA { public string MyProp { get; set; } publi...
In swift the compilation time is really slow the amount of code in your project increases. So i was looking for ways to reduce that time. One approach maybe is to use language keywords like final or static to change the way the compiler handles the code in this case using static and dynamic dispatch. But as far i read ...
We have two products let call them X and Y. Product-X is established and has numerous clients over continents whereas Product-Y's development was started a few years ago and it has yet to enjoy any client. We came across a scenario where we have to sync data and actions between both systems. This can be done at any sta...
I'm currently building an interactive game which has a very special use case : The game is displayed on a giant screen on stage in a theatre, and the audience can play it with their smartphones (http://www.augmented-magic.com/) My tools are : A desktop app made with Unity, displayed on stage A web server (RoR) who pro...
I'm making a physics engine and its becoming quite hard to keep track of the whole thing. Often when I get back to my code after a break I just don't remember why that's not working. Most of the issues aren't simple programming mistakes but design flaws in my physics engine. That's why I should just finish designing it...
My current web app provides a service to clients on a single site. It is NOT eBay, but I will explain using eBay as an analagous service we can all understand. A client sets up a page, and other peer users can go to the page, do business, and the site charges for the service, the trades done. Currently my site is monol...
Generally I use private methods to encapsulate functionality that is reused in multiple places in the class. But sometimes I have a large public method that could be broken up into smaller steps, each in its own private method. This would make the public method shorter, but I'm worried that forcing anyone who reads the...
I'm not sure if this is the right site to ask this question. This question is not a duplicate of this one. So a few months ago I discovered project X on Github. Some info on project X: X has a lot of stars on Github (~3k) X has not been actively maintained for almost a year X has a new version being developed seperate...
I'm new at writing professional code (the bulk of my experience is with personal projects) so excuse me if this is trivial. When I write code I find myself being a little inconsistent with how much functionality I include in one function. If I know it's code I'm going to reuse later I'll make a separate function, but w...
I'm planning to design and set up a database to store dictionary entries (usually single words) and their meaning in another language. So, for example, the table Glossary must have entry and definition and each table record has a reference to the id of a record stored in Tag (Each entry must have a tag or category). Si...
I normally have a laissez faire attitude on method naming conventions but now I am working on a module in JavaScript that will have some methods that can return the value directly (immediate / plain function), and others that must be asynchronous and work through callbacks / promises / etc. I think it would be preferab...
I'm a Sr. front-end dev, coding in Babel ES6. Part of our app makes an API call, and based on the data model we get back from the API call, certain forms need to be filled out. Those forms are stored in a doubly-linked list (if the back-end says some of the data is invalid, we can quickly get the user back to the on...
I have a class that would highly benefit from Unit tests, but few methods that call remote web server must be replaced by something delivering mock results. The probable solutions I see are: Test the derived class that overrides problematic methods (no test-related code in production, just methods must be non-private ...
I'm really only looking for pseudo code here. I'm trying to write a binary search algo which finds the location of a value in a series of values (or the location of where a value should be in a series when the value doesn't exist). I'm getting hung up on rounding when the amount of values in a series is odd. I'm not su...
I'm working with an MVC framework to build a simple Q&A web app, and I am trying to grasp the idea of controllers acting on the app. For instance, say I have a home page with the following links: Home > Login > Home > Profile Home > List of questions (updated dynamically) > (new view showing) One question Home > List ...
How to identify when to use an user or a system definition of a requirement? In the example below: Use case: List Posts by status Pre-conditions: The admin is authenticated. There are items registered in the system. Trigger: The admin wants to list the posts according to its status (published, draft) Ator: Admin...
I just want to know if its possible to create an app without data storing all of its user data, instead each new user’s mobile device becomes a new server. Is this possible? if so, how to do it? How can I accomplish this? This ideia came from the movie "Nerve". I let the movie details down below. Nerve IMDb Nerve trail...
I'm trying to get past all the hipster, pie-in-the-sky buzzwording and address a very simple, fundamental question: What is a streaming application? According to the Kafka site "Kafka is used for building real-time data pipelines and streaming apps" Streaming apps...hmmm. OK, so what is a "streaming app"?! According ...
I have several postgres DB, on distant sites, two in China, 1 in India , one in Korea, one in Germany, one in France and one in Mexico. All dbs, regardless of their site, have one table that is part of a schema. That table is updated through an excel spreadsheet. The spreadsheet is filled by a physical person. Joe wil...
Generally speaking, is it acceptable for a web MVC application to use REST endpoints for it's data access layer? I realize this would make practically every request cost 2 requests and that doesn't sound nice. What I don't know is if this is a "valid" or commonly used approach.
I got a question about team managing. Right now I'm dealing with a junior developer who's working remotely from a coding factory. The guy is open to criticism and willing to learn, but I got some doubts how much should I push some stuff. Right now when something is straight and obvious a violation of good practices: li...
I'm am trying to understand machine code memory addressing for x86, and I've encountered two opposing general forms for addressing (using the ModRM and SIB bytes). Most unofficial resources I consult suggest memory addressing is done in a subset of the general form [register1 + scale * register2 + displacement]. An exa...
The other day I was playing around with an experiment and I had a for loop something like so: for (Node node : children) { // do stuff with node ... } And then I changed it to do this: for (Node node : children.stream().filter(n -> n.isCreated())) { // do stuff with node ... } And got this error: Can only iterate...
I am designing a DSL (in clojure, specifically; though this question is more general than that) in which 'entities' are tracked as immutable hashes/maps, and where the 'concept' membership of an entity is dynamically determined by the keys and values of the maps. A toy example of how this would appear: (defconcept Ann...
I'm writing an application on x86_64 CentOS 7 that functions as a server, managing potentially thousands of devices. Because my application doesn't do so well when running through the connection process (various application-layer handshaking, DB operations, etc.) and it's conceivable that thousands of devices could com...
Without getting into specific language or implementation: The value of the variables are not known until runtime. All instances of this class will need this variable. The obvious solutions: Use a static variable that I set before I start using that class, but this feels messy because any user would have to remember ...
Suppose I have 2 features to be delivered (A and B). I have two primary branches (develop & master) for staging and production servers and 2 feature branches (features/a and features/b). When a feature is ready, I merge it to develop branch for testing. Let's assume that there wasn't found any bugs in feature A but the...
When breaking up a large monolithic application with a monolithic RDBMS into a service-oriented architecture with many databases, how do you deal with the breaking of data integrity? I have a large monolithic application. My team has agreed that it's beneficial to break up this monolith into domain-specific services a...
According to the Kafka site: "Kakfa is used for building real-time data pipelines and streaming apps." Searching the internet far and wide, I've found the following generally-accepted definition of what "stream data" is: Stream data is data that flows contiguously from a source to a destination over a network; and S...
When software is being developed in an engineering concept, some form of assurance validity must be met, this is in order to measure requirements in each stage of the SDLC. In developing a Software Quality Assurance, guide I came across a reference to Software Quality Plan. They are both similar in structure and my und...
I wish to test the following method: class MyClass(object): ... def my_method(self, args): ... # Code which transforms args into arg1, arg2, ..., argN self.A.other_method1(arg1, arg2) self.A.other_method2(arg1, arg2, arg3) self.A.other_method3(arg1) self.B.other_method4(...
I have read plenty of questions on here, which appear to confuse the MVP/MVC Model with the Domain Model. In my mind the MVP Model calls the Service, which then calls a rich Domain Model i.e. the MVC/MVP model is a view model.. I have seen a lot of code, which does this (this is the MVC Model): public class Model : IM...
I have an app and a list of all the actions a user has done while using it. To put an example, for each user I have data like this: "start" "country":"aa" "session":"0" "menu":"main" "menu":"play" "play_level":"1" "play_during":"70 seconds" "purchase":"metal hammer" "play_level":"2" I have to choose a database where ...
I need support for Angular2 service architectures. I am quite familiar with Angular2 but I don't see the best way to implement services, error handling and their connection with the components. I'm aiming at small-middle-sized Angular2 applications having not more than a few couple (<100) pages. These are my main dile...
I'm a full stack web developer, I've been looking for a job lately as a junior since I don't have experience with working for companies, but I've done some projects in the past from design to deployment(for about 6 years). In a job interview, I had lately I've been asked what I think is a weird question in the context ...
In our team we have some low / medium level developers: they know how to write C#/JavaScript code, but most of it is an anemic domain model in a purely functionnal way of coding, but there are no unit tests, SOLID principles are not being respected, anti-patterns are a common practice, only the coding style conventions...
So I've been developing an API for the company I work for for a year. Recently, I plan to move to another workplace and have done an interview with the recruiter. She asked to see my GitHub page for code review. To tell you the truth, I'm still a rookie (the API I mention earlier is my very first professional work in p...
I'm working on some code that checks for some invariants in the database. For example to check that an element is not repeated the code checks for a database error since the invariant is coded at database level. Basically to enforce uniqueness for a certain set of key the code checks for the error: if (sqlError = "name...
I've just done a code review where I came across a method like this: private void FindMinAndMax(double[] values) { // Some algorithm that results in two class vars being assigned: _min = ... _max = ... } (After returning, the calling code utilises these two values in various calculations; the calling code ...
We want to practice proper software engineering for our project and allocate some task to do it. Problem is, I don't know where to put it. Previously we have epic & user stories like: As a developer, we must observe proper software engineering so that we maintain efficiency As a developer, my code should not be merged...
We are writing Spring4 based REST services and had a question about returned HTTP status codes. It looks like the generally accepted approach is to let the app server or web server container handle the responses when the HTTP protocol is not met. For example 500 Internal Server could imply that the apache server int...
Say I have an MVP app. The form has four textboxes: Quantity Price Product TotalPrice The app calls a web service and then recommends products that may be cheaper based on the quantities being bought. Is it acceptable to set the total price on the client using a setter, i.e. TotalPrice = Quantity*Price or should ...
I am making an application that will allow user to store and execute simple scripts using Web GUI. Web GUI is ASP.NET MVC and scripts can be of any kind (Python, Perl, AWK, CMD, PowerShell ect. User just needs to provide path to executable). Also there are scripts that do not require executable like XSLT, IronPython ec...
My understanding is that [Flag] enums are typically used for things that can be combined, where the individual values aren't mutually exclusive. For example: [Flags] public enum SomeAttributes { Foo = 1 << 0, Bar = 1 << 1, Baz = 1 << 2, } Where any SomeAttributes value can be a combination of Foo, Bar and ...
The create and update methods in my model base go through a few steps: pre_save, udpate_database, post_save. The pre-save and post-save are specifically designed to help with object-relational impedance mismatch. The idea is that any database operations that aren't a simple "save value X to column Y in the table" are...
let's say that I am working with an IoT device. The device can have many sensors, each of them has an address, i/o direction and a reading method. temperature=d2,input,digital humidity=d3,input,digital lcd=a1,output,analog From my program, I should read this configuration file and start getting data for example from t...
While coding anything remotely useful, I inevitably find myself wanting to add methods to perform smaller bits and pieces. (It could be a method to return everything in a string to the left of the first occurence of a particular character.) Over time, writing such methods will propably form into some kind of library. W...
I'm writing a library that has a lot of information that may be of use in a log in the program which uses it, but I don't know the best way to expose it in such a way that the program using my library can integrate my library's logs with its own logs seemlessly (if desired). Picking a specific logging library for my li...
Our application stack looks something like Java 8 out of Tomcat 7, several distinct Postgres databases, Maven for build and Jenkins for CI. I have fully automated my team's build process using except for one missing subprocess: database (schema and/or data) changes. Once a change is committed to version control, a new ...
Git by default does not set the file-time accordingly when the files are synced with the origin. It just ignores the file-time of the pushed files. Doesn't it make sense for the file's modification date to be set to the value of the last commit (remote or local), rather than it leaving it the same as the date it was fe...
I have a Playframework application written in Scala. As you might expect, it's primary function is to respond to user requests. Typical request flow: Parse input and figure out what the user wants us to do Gather external resources from db, AWS and so on (relatively slow, async IO calls). When IO calls return, execu...
Context I want to design a procedure or system task to load into a database, data that's needed by the system in order to work. The easiest example I can come up with is a ACL (or RBAC, not sure which one is the right term) where an user need permission to perform certain actions (create a resource, view a resource, vi...
I've seen some posts which has strong reason to avoid using protected: Why have private fields, isn't protected enough? Why is Clean Code suggesting avoiding protected variables? And there are some other posts suggested we don't need inheritance actually: Why should I prefer composition over inheritance? And some other...
Is there a "rule of thumb" to when it is right to take partial result from a table, rather than the whole table? Consider my current dilemma: SQL view that has total of ~1200 items, the view is not so complex only joining from several tables. Query for some property, total results ~600 records Using on UI with ng-repe...
How do I manage and update two different app versions, which are with and without advertisements, but are otherwise identical, using git. Up to this point in development, I've only needed to maintain one branch.
Context: I have recently joined a new company where they have a particular folder structure in the project where they have different modules in different folders in a single project. Each module folder has separate submodule and then separate child folders for back-end(in Python) and front-end(in AngularJS) code. Separ...
I made an auto complete text box for an application I'm working on. The text box basically has an associated list that it searches each time you enter something in the box. If you enter something that is not in the box and hit 'OK', the item is added to that associated list in it's sorted position using a binary insert...
I have an API which returns a list of articles. An article can have three status: Approved, Pending and Rejected. Now the front-end needs to hit the API in following scenarios: Get all the articles irrespective of the status. Get all articles added by an user. Get all articles added by an user which are pending/reject...
I have couple of models Merchant and Offer. A merchant can have multiple offers. I am developing a web application and writing a custom component which show offer details like title, description etc. I also need to show merchant thumbnail in the same component. The data I have is offer list in JSON and each offer conta...
I understand test-driven development so far that you are only allowed to write productive code when you have a failing (red) unit test. Based on this I have the question if the test-driven approach can also be applied to other forms of tests.
The syntax 3 of protobuf made all the fields optional dropping the keywords required and optional from previous proto2 syntax. Reading some comments from developers it seems that it was done for enhancing forward/backward binary compatibility. But for me, that could be enforced by just versioning the package names, sa...
I just started working on a new project and no one throws exceptions over here. I get that you shouldn't be doing that for asynchronous code, but it seems to be a valid way to do things for the synchronous side of things. I would typically do something like this: function(thing, cb) { async_funct(thing, function(stu...
Say I have an MVP app. Should the Presenter handle events raised by the view. For example, please see the code below: public void TextBox_TypeValidationCompleted(object sender, TypeValidationEventArgs e) { //do something } and the code below: public void Button_Click(object sender, EventAr...
My job is to come up with an implementation to save searches linked to an individual user, as well as the ability to analyze this data for business cases. The data will be used for users to see their search history, and for data mining to get insight in user behavior It will be implemented on an app to find houses, the...
Now that we have const implemented javascript we can use it to declare variables. But unlike let or var it is 5-character long and I believe it is a big deal actually. Something that even slightly takes longer to type (and read) affects our coding experience. My question would be - say, one is trying to come up with s...
I'm working on yesod application which has routes like /make/something MakeR POST on which server generates an object and returns its ID wrapped into JSON. I use Int as ID. So, I ended up using a data types like this data Manager = Manager { objects :: IntMap Object , nextId :: Int } I store them in TVar in ...
One of the common arguments for using microservices is better scalability. But I wonder whether this argument is really valid. Lets say we had an application consisting of 10 microservice with 9 of them having each two instances (for redundancy) and one of them with 4 instances to handle the load (scalability). The pr...
I have an acquaintance, a more seasoned developer than me. We were talking about programming practices and I was taken aback by his approach on 'if' statements. He insists on some practices regarding if statements that I find rather strange. Firstly, an if statement should be followed by an else statement, whether ther...
I find myself often having a function, for example authenticate: authenticate(user, token): # do authentication and a dictionary created by reading a configuration file, like this: conf['general']['auth_user'] conf['general']['auth_token'] My question is, in terms of best practice (python in specific), should I j...
I am trying to give value to a certain package and library by building some usage stats. This package is written in python and invoked/imported by users on remote machines/cluster What we are trying to do is to set up a certain tracking mechanism that will register or log every time someone imports the package and idea...
Firstly i hope im in the right place to ask this question. I am building a web page that allows the user to select one image from a set of a 100+. i want to display them 6 at a time and the user must be able to search trough them (preferable key up search). My first implementation queried the Database and returned th...
Usually on Php or in Java and in other single Inheritance Object Oriented Languages, when I am writing a software I use and Interface then and afterwards I implement the class that implements the business logic. For example let us suppose we have a File Uploader that allow us to Upload into various ways in our case int...
I am developing a web application and struggling to follow a clear semantic while returning response to the client. Taking an example of authenticating an user there can be following scenarios: 1. Request is successful The user is authenticated and I send a JSON response {success: true} // and an optional message field...
void Animation::playAnimation() const { static const int index = 0; const std::string& animationFileName = m_animationContainer.getAnimationName(index); static const int zOrder = -1; static bool isLooping = false; AnimationBank::play(animationFileName, zOrder, ...
I've got a Python webapp running in docker container and a DB container/service, and I'm wondering if the apache/mod_wsgi functionality should be contained within the container that runs the python app itself, or separate. I'm currently running them together, but I've seen graphics like the one in this article which de...
I looked at using python for the AI in a security application for hobby-business but apparently you either release it as source code or it can be easily decompiled. Of the new machine learning languages/packages, which can be kept confidential? Likely I would use it to identify between good and bad traffic and content...
Currently working on an accounting application. Wrote the GUI framework from the ground up with Win32 and it works well. The issue I'm having is trying to separate the GUI from the application logic. The classes I've implemented so far are: class Application class MyApplication : public Application // Is this my contr...
I work in a small contracting firm doing small custom projects. We have this continual problem where the customer wants to be responsible for testing the final build to save some money. Most of the projects are reading from a file from one system and creating orders or whatever in another system. So the customer figure...