instruction
stringlengths
34
36.1k
I have several Oracle database where my in-house applications are running. Those applications use both dba_jobs and dba_scheduler_jobs. I want to write monitoring function: check_my_jobs which will be called periodically by Nagios to check if everything is OK with my jobs. (Are they running? Is it Broken? Is next_run_...
Background: there'a a gazillion types of virtual machines in Microsoft Azure each having different performance and price. Such virtual machines are paid per hour. The goal is to decide how to get "the most for the money spent". This can be also reworded in terms of electricity spent for a certain amount of computation....
After reading the book; I understood the following: 1) Entities should implement equality and compare by ID. 2) Value Objects should implement equality and compare by all properties in the class. I still believe that my understanding of point two is correct. However, I am confused about point one because of the follow...
We have a microservice that reads in large data files, each row containing information about Accounts. For each record found, it will then go off and do other "stuff" and that stuff is distributed across other microservices. As such, we need to look at using correlation IDs to tie distributed transactions together from...
I am looking to perform a large overhaul on a complex simulation system that simulates several instances of several vehicle models in a classroom training environment. For example, 24 students may be running simulations on three different vehicles for maintenance and operation. Instructors will be required to have ta...
While reviewing some code, I noticed the opportunity to change it to use generics. The (obfuscated) code looks like: public void DoAllTheThings(Type typeOfTarget, object[] possibleTargets) { var someProperty = typeOfTarget.GetProperty(possibleTargets[0]); ... } This code could be replaced by generics, like so:...
Hopefully this is the correct channel for such a question and my quest for further knowledge. I've currently built a significant platform which allows clients to communicate with our API, which in turns allows "items" to be pushed to a print queue. Most third party developers and app users have no problem consuming the...
I'm torn between using DI and static utility classes on my code. I currently created a DateUtil static class that is only meant to be accessed statically. This class is responsible for just creating and manipulating dates using a variety of libraries with absolutely no external 3rd party dependency. Everything looks f...
I inherited a Visual Studio solution with a Main branch, a QA branch off of Main, and a DEV branch off of QA. It seems these are the only branches and they've existed for the lifespan of the solution. The solution has 5 projects, and in our new version I want to create a different behavior for one of the projects, but ...
I hosted a hobby NodeJS Server from my Linux and all is fine by accessing my direct IP. Because I find this ugly and also less secure, I decided to route my domain which is set to Cloudflare to my IP. Then as I access the URL, I was prompted with an Authentication that I had never set up. The question is, why proxy-in...
I have a python package that I wrote and I want to use it within multiple docker builds. However, I can't just install my local package situated outside of Dockerfile folder. And I don't want to copy the package into multiple projects. So how do I keep my architecture DRY?
Is it a good idea to have individual/unique data sets for each integration test or should all tests reuse the same data? My idea for having individual data sets for each test is to have more control for each test to make it easier to update old tests as well as implementing new data. Instead of making sure the new data...
I was reading this question recently: ID properties on Domain objects in DDD The question talks about having an surrogate key in the infrastructure layer, which is a database ID. I use a Guid for this: Guid id = Guid.NewId(); The answers then talk about having a natural key in the domain layer that identifies the enti...
I have a RESTFUL api, one of the endpoints is receiving search criteria which contains property for "Title". Should I allow consumers to send either null (or eliminate the property) or Empty string in this property and deal with both as the same meaning in this context ? I mean, for me I shouldn't do search with null, ...
I have a unit test similar to the code snippet below, it should check that the AddUser method only allows unique emails. My question is around the Arrange part of this unit test, I use existing system code to setup the first user (class UserLogic), this is so that I have a user in context to perform the next parts of t...
Note I realise this could be subjective question to answer, but I don't expect an answer in the form of "Do this and everything will work out". I am aware there will probably be some decisions to be taken and that different approaches are better for different scenarios. In any case, I would like a review of the pros an...
I have a class Tiles that looks something like this: class Tiles { public: void AddTile(int x) { tiles_.push_back(x); } std::vector<int> tiles_; } Now I want to create a class Tiles with data, i.e., class TilesWithData : public Tiles { public: void AddTile(int x, double data) { tiles_.push_back(x); da...
I have an address as part of my domain. The address keeps information about country, city, zipcode, street and housenumber. It is used in multiple places - a company can have an office address, invoicing address and/or correspondence address; transports have addresses at start, middle and end points; couple of other pl...
We have int i; which have 4 bytes lets have address from 1000 to 1004. if we declared a pointer int* p; p = &i; now is the pointer holds only 1000 or from 1000 to 1004? The pointer holds the addresses then why we need to declare a datatype to a variable? when we declare a datatype to pointer, can a pointer can be ...
In my project I have some constants where I reference almost everywhere: public sealed class Constants{ public static readonly int MAX_QUAL { get; } = 1080; public static readonly bool CC { get; set;} = false; } Is it a good practice to store these values in in the application code itself, similar to the snipp...
I was really glad that ES6 introduced the let keyword for defining variables. var scoping rules can lead to all kinds of issues, especially when working with loops and event handlers. Even when programmers used var in the past, they still almost always expected let scoping rules. Variables declared with var are availab...
I'm currently developing an application using reactive programming. Every entity creation or modification in the system publishes an event and no two entities can be created/modified within the same use case. In this situation, there are entities that have to be created based on specific states of other entities. For e...
I need to implement a class hierarchy and be able to implement it in multiple ways. I want to create a logical representation of a query language, and then be able to parse it to/from different formats (XML, JSON, YAML, etc), and switch between them. I tried to start with the classes below (Logical Hierarchy) to repre...
I'm trying to figure out the best option to mark a database entity that could be closed manually or automatically. This entity already have a status that accepts OPEN or CANCELED. Now, I would like to "close", but the close action can be manually or automatically, and I will need this information in the future to know ...
I'm writing a really simple interpreted object oriented programming language with a C-like syntax. I've been looking into type inference and I've found a few implementations of the 'Hindley-Milner Type Inference' system. Most are in functional languages, which I can't read, but I found this one written in Python that ...
As an example, say you are writing an app in Java. Your app communicates with an API server written in Python. The Python server communicates with an SQL database. You also have a website for your app written in JavaScript. With 4 different languages, it's easy to end up repeating essentially the same data structures 4...
In a nutshell what I need is a simple good practice for multiple (loosely coupled or tightly coupled), git repositories I would love to hear there is a good framework for that, but I have read a dozen other s.exchanges threads and most simply give a compromise solution, and only one suggested "have a good practice" .....
I am storing information about Widgets in my database, and each Widget has one (non-unique) transformation function associated with it. My problem is how to associate Widgets with their transformation function. My first instinct was to use an enum for the transformation function. I am using sqlalchemy for my database O...
Is there a way to implement the traveling salesman or purchaser algorithm with constraints between locations? For example, I have to grab item X before item B, c before D and F,G,H in any order.
I'm in the process of designing a server responsible for serving files that are between 10MB and 50MB in size. Initially we will run two instances of the server (lets call them fs1 and fs2), with future plans to switch to a micro-service architecture, where the server instances will grow or shrink depending on the load...
We all know that Scrum works very well for a traditional team where team members come into work each week/sprint, agree goals and meet commitments. However open source projects are often very different: People tend not to work on Open Source projects full time While some projects have a group of core contributors many...
For example, if I have a game which have some components, which has Player and Enemy,as well as the parent container,Game, e.g.: Version 1: public class Player{ private int hp; private Label hpLabel(); //some other properties } public class Enemy{ private int hp; private Label hpLabel(); //som...
Say I have a data model, which looks like this: public class DataCustomer { public virtual System.DateTime CreatedTime { get; set; } public virtual Guid Id { get; set; } public virtual string FirstName { get; set; } public virtual string Surname { get; set; } public virtual string FaxNumber{ get; s...
While working on a web (JEE based) application I saw some different ways people have instantiated loggers in different classes. First way is classic way like, private static final Logger logger = LoggerFactory.getLogger(AbstractPersistenceObjectDAO.class); but as JEE applications are CDI enabled in some managed classe...
My understanding of story estimation has been that one should estimate the size of a story as it would be for an imaginary, average developer — a bit like the "reasonable bystander" concept in law. That is, you should not estimate the story's size assuming you have to do it. To give an example: in my previous job I wa...
The Eclipse Scala IDE (and Intellij Idea, too) has, together with a standard REPL CLI, an artifact named Worksheet, that works like a persistent REPL log: the whole file is compiled and executed at save time, and the results are in-lined as comments. It is a great tool for API exploration and design, and initial testin...
I'm currently working for a company that uses VSTS for managing git code. Microsoft's "recommended" way of merging a branch is to do a "squash merge", meaning that all commits for that branch get squashed into one new commit incorporating all of the changes. The trouble is, what if I do some changes in one branch for ...
Assuming that the entire product team has agreed that implementing some automated end-to-end tests* is worthwhile in the first place... By what criteria should the workload of implementing automated end-to-end tests be distributed between developers and dedicated QA (automation) engineers (or some other role)? *I'd pre...
When planning our database, we ended up with a setup like this: We have Company, Product and Person. There is a many-to-many relationship between Company and Product, through a junction table Company_Product, because a given company may produce more than one product (such as "car" and "bicycle"), but also a given produ...
I am trying to figure out the best way to keep objects in memory without having them scattered everywhere within the code. For example: I have a PyQT menu system which interacts with objects. Currently, these menus are able to create and modify an object by hitting code outside of their menu-related files, but afterwar...
I was wondering about client side vs server side calculations regarding websites that provide some convenience type service. For example, an online website where you input a certain date and the website tells you how many days between today and that date. Or a website that tells you steps to solve the inputted math equ...
I'm dealing with a design problem. Actually I have the following architecture: A Process interface : public interface Processor { void applyNewConfiguration(final Configuration conf); Result process(); } A processor MyProcessor which implements this interface : public class MyProcessor implements Processor {...
So memory segmentation can be done with or without paging. I always hear people talking about stack and heaps when discussing something memory related in C++. However, what I do not get is that if the program's memory (its virtual address space) is segmented using pages, it won't get divided into stack, heap, etc., rig...
I have recently learned C and want to start a project to solidify my knowledge. I've settled on making a very simple text editor, something like vim. The problem I face is that I genuinely have no clue how a text editor even works, and I don't know what to google for to learn about it. Googling about it led to vim's Gi...
I am currently reviewing some of the code of junior developers who just joined my team, I am wondering how should I deliver the output of this review: Should I fix the code myself? Should I give them feedback on the review process and let them do the fixes according to my instructions? And if so, how do I give this fe...
Is it considered bad practice to call for example tshark or ffmpeg in my code, assuming I couldn't find a good enough library to use?
I’m writing an asynchronous, Promise-returning function. In the processing I test some conditions, and if the conditions pass, the promise should be fulfilled (resolved), but if one fails, then the promise should be rejected. I want to know which is the preferred coding style, or which is more readable, when writing pr...
While I do see the benefits of IoC containers (as I've used them a fair bit), I don't see how they can be incorporated within TDD unit tests (note, I'm only interested in unit tests here, not integration tests). When I TDD, I refactor constructors to use IoC, so that I can inject fake dependencies wherever I might need...
Project 1: a Java/Maven project Project 2: a Scala/sbt project Thing: generally, an immutable object instantiated in from 3rd party Java library. For example, ThingBuilder.foo("bar").build() Question: How can I define Thing in only one place, and have it used both in Project 1 and 2? (So the parameters in ThingBuilde...
Is 'call site' some auto code generated by compiler - I come across this term frequently and it sounds like calling method is simply referred as 'call site' - which literally sounds fine but I believe it has some deeper intricacies. And if 'call site' is compiler generated code - under what circumstances this is requir...
I have read this article, but I still really do not know a programming model is. I saw it being used in the following context: Any given instruction set can be implemented in a variety of ways. All ways of implementing a particular instruction set provide the same programming model, and all implementations of that...
Let’s say we have the following abstract class HungryAnimal { private MovementStrategy movementStrategy; public HungryAnimal(MovementStrategy movementStrategy) { this.movementStrategy = movementStrategy; } public void searchFood() { while (/* no food found */) { ... ...
I imagine it is simply, as it is named, the existence of data throughout layers of a software application. I ask because I have not been able to find a clear definition that states something of the sort: Data Persistence is the existence of data throughout layers of a software application. If that exists please share t...
The definition of production seems to contradict what web developers consider an application in production to be. Why is the term in release or published not used instead? I have been in professional web development for ~4 years and we've always used the terminology (development, QA, and production) when referring to t...
I know that the Arithmetic Logic Unit (ALU of a processor performs arithmetic (and bitwise) operations and the result is stored as the ALU's output - but what component, device or software is actually accessing/using the output of an ALU? And is it valid to say that the ALU returns the result of an operations or would ...
For example, consider I have a class for other classes to extend: public class LoginPage { public String userId; public String session; public boolean checkSessionValid() { } } and some subclasses: public class HomePage extends LoginPage { } public class EditInfoPage extends LoginPage { } In fact, ...
I am designing a role playing game. In such games there is a character that has a level. I found out that the level itself is an object. It has values like experience, the knowledge of how moch experience is needed for a level-up, and methods like improve() or gainExperience(). So the character should have a level obje...
So an addressing mode is the way that an operand is specified (from what I understand) and there are different modes provides by different architectures, such as Immediate mode, register indirect mode, etc. In that context, I frequently encounter an a specification of an offset, such as in the direct mode where you sp...
I am facing an issue where I have a data stream that sends unordered data. I'm trying to find a way to receive the data in random order, but send it in order. As an example, I'll receive object4 and then object3 and then object1. I'll need my system to store object4 and object3 when they arrive and immediately send obj...
I'm writing this in node.js I have some data that needs validating before anything can be done with this. The data is validated in two different ways. I can use JSONSchema to validate the structure of the data e.g. the data must contain a name property of minLength 1 and maxLength 100. I then use another validator f...
EDIT I am working on a project to update a legacy ETL infrastructure that supports a number of clients, each with a slightly different setup. Constraints that cannot be changed: Source data can come from flat files over sftp and then to S3, from MSSQL databases, or events published through webhooks. Source data rang...
I have a neat domain model that makes it easy to communicate with an external web service. New requirements have made the external web service's interface messy and now I have to gather data from multiple places in my model. Is a DTO appropriate to hold all the necessary data? I have an interface that deals with searc...
We have three environments: Dev, UAT and Prod. We use TFS to schedule releases of our master branch into Dev for our internal verification, then UAT for business verification, and of course finally to Prod once approved. We've recently adopted a new lightweight Git branching strategy as follows: master is always prod-...
I'm building a REST service in java that does basic CRUD operations on Customers. The easy way would be for me to create one Customer model, and annotate it with JPA annotations so my persistence layer knows how to map it to the DB and add some jackson annotations so that my web layer knows how to deserialize it from h...
Say I have an MVC .net core website where 100% of the controllers/methods are behind [Authorize] attributes (complete with policies and all). Would it be taboo, to carve out a set of un-authorized/anonymous controller/methods to handle user requests for access to the site. It seems perfectly reasonable to me, and outs...
In a multi-tenant deployment of Web application, How can the Asp.Net Core Web API services be designed to work with different authorization services? The Web applications use OAuth and JWT Bearer authentication and pass access token to the Web API services. One approach that I could think of is to, get the Authority ...
OK, so the title is a little clickbaity but seriously I've been on a tell, don't ask (TDA) kick for a while. I like how it encourages methods to be used as messages in true object-oriented fashion. But this has a nagging problem that has been rattling about in my head. I have come to suspect that well-written code can ...
Let's say my app depends on lib A that depends on B that depends on C (we are owners of them all). Now, you bump the version of C to 1.0.1 (a bug fix). How would you propagate the change of C to the app? Would you bump versions of B and A, too? What if there are frequent changes of C needed across the teams? Do you rel...
We're completely remodelling a system at the company for which I am currently working. We're applying DDD and for the very first time I have actually got someone on my team who has some prior experience with DDD as well (yay!) This new system is extremely user-centric, i.e. pretty much every operation within the system...
Using PHP, I created a chatbox, and I used an unorthodox way of storing chat messages in MySQL. The tbl_chat_messages has the following columns: id | sender_id | receiver_id | message | date The actual messages are json_encoded, and is then stored in the message column which has the datatype of Longtext. It is structu...
I have recently come across a design question and will explain it using an imaginary scenario: Assume you need to retrieve the days where there are no bookings for a given date range. You could filter the results and manually identify what date is not contained, but you'd be getting the booking information unnecessari...
I have been working for quite a lot of time on a research project at University focused on Access Control. More specifically, I am studying how to protect unauthorized access to personal data in a distributed system and in general in the Internet. In this context, I stumbled on the XACML (wiki, official spec) specifica...
In the company I work for, I keep seeing IManager interfaces being converted into their real types and lots of "instanceof / TypeOf" if statement checks. For example: IManager manager // passed to method as a parameter if (manager.GetType() == typeof(CustomerManager)) { customerManager = (CustomerManager) manager;...
I am writing a simulation engine consisting of a number of components, each of which operates on a fixed set of shared buffers. In practice, the simulation will run entirely on the GPU. When developing a component however, it is easier to copy the buffers from the GPU, execute the component on the CPU, and write the up...
Recently I have been trying to avoid down-casting object types from an interface type to their concrete types, and 'if' statements that check for an objects concrete type at run-time. This has made me ask myself a question; Why add public methods to concrete classes that also implement an interface? I ended up making a...
We have a bunch of appSettings in our ASP.NET web application, not to mention connection strings, that change on a per-environment basis. Not just for different environments to which the web application is deployed, but across different developer machines too. Therefore, changing these with a Web.config transform isn...
What is an empty method and how are they used? I was reading a documented about the BUILDER Pattern and I got a curious about how it is implemented in C++. The author defines that in C++ could be possible to implement empty methods as default in the builder pattern in order to letting clients override only the operatio...
I don't know if the title is reflecting the question correctly, but I can explain more than write a good title. If I have a database that has (employees, departments, orders, etc...), and have many ways to call the endpoints of this system, and each way requests data less or more of the same entity (e.g employee ent...
In my project I have different types of entities. I get the data for these entities in text files from a 3rd party. I've written a class to read and parse these text files, using the strategy pattern. The method in this class must return different entity types so I've made the entire class generic - something like this...
I work on system with such architecture: There are two types of components, let’s call them CLIENT and SERVER. There is only one instance of CLIENT component and there might be multiple instances of SERVER component. CLIENT uses HTTP interfaces of those SERVERs (they are the same interfaces). What diagram should I us...
I found an interesting quote in my book with which I learn Java: Manche Methoden der in diesem Kapitel beschriebenen Schnittstellen sind in der Dokumentation als optional gekennzeichnet. Bei manchen Collections-Klassen führt die Nutzung solcher Methoden zu einer UnsupportedOperationException . Sie dürfen sich al...
Backstory I am writing a library that accesses the kernel module, uinput which allows you to create or take control of devices in /dev/input/event#, and insert events into them. A simple usecase would allow someone to write a script that would move a mouse cursor to the center of your display, and perform a left click....
When designing a RESTful API, providing a spec for updating an entity will force the designer to make some decisions on how the update will behave (an update mode or type). Here are some of the modes I can think of: If the update body contains null values, ignore them and only update the values with non-null values. ...
I'm creating a software that's supposed to accept a certain form of data and does something to the data. We decided to create a small dependency beforehand which will be used to make the development of the software smoother. We're planning to accept support for json, csv, yaml, and sql files/url's(consuming rest) and c...
First of all, yes I'm aware of PEP8 and the alphabetical method. I do sort my imports first by the PEP8 recommendation: standard library imports related third party imports local application/library specific imports But then, within each category, I like to sort by the length of the module name. Yes, it makes...
We want to pull application and business metrics from the source web application to track billing, usage and performance of the application. These metrics are to be stored in a different database (Oracle) for further processing and analytics. We would be building analytics dashboards over these metrics that would be pr...
We are developing visual controls for WinForms in .NET, and one of our customers using our products is still compiling all his apps for .NET 4 Client Profile. He has to do this as his customers, some larger companies, would not allow the full install of dot net framework since it contained security risks that were unac...
I'm new to this Repository pattern and have seen lot of repository pattern + UoW implementations all over the internet and I'm not able to reach to a conclusion as to which of them is correct . After going through many links I've been able to implement one . Considering the following points in mind It should satisfy ...
I am developing my own header-only library that I want to use as a framework in other software. I am using CMake for setting up demo targets, tests, and so on. However, I am unsure how to deal with dependencies of my library. Currently, I am using the following approach: FIND_PACKAGE( foo ) I have a configuration conf...
What is the best way to inform users that there has been a bug found in some software they used? For example, let's say a user finds a bug in some software and reports it to the development team who decide that fixing this bug will be done in an upcoming release (rather than a one off patch) due to it being low risk (v...
I have a list of 75000 websites that need to be monitored for uptime. Monitoring the websites involves making a HTTP request for the website every minute, and the website is said to be "up" or "down" based on whether we could successfully make a HTTP request and received a HTTP response. This kind of "polling" is the o...
I am about to start coding for a school project that requires me to demonstrate good OO practices in a web app. Now, I have built a few web apps and have never felt the need to define my own classes and utilize objects (outside of classes provided by frameworks and modules) so I was looking for help in making some des...
Once in a while, I leave comments like # We only need to use the following for V4 of the computation. # See APIPROJ-14 for details. or # We only need to use the following for V4 of the computation. # See https://theboringcompany.atlassian.net/browse/DIGIT-827 for details. My main concern with doing so is that it inc...
I have data that is structured like the following: users: id | name | parent_id 1 | Bob | NULL 2 | Jan | 1 3 | Mat | 2 4 | Irene | 2 5 | Ellie | 2 6 | Laura | 5 7 | Uma | 6 user_sales: user_id | sales_period | total_volume | total_revenue | .... 1 | Jan-2017 | 1000 | 56000 1 ...
I am writing some code to parse some files (which I call "assets"), and I'm planning to structure this as three classes: AssetParser, NamespacesParser, and TransfomersParser. AssetParser will use objects of the other two classes to parse some parts of the assets. I want to write this as three classes rather than one bi...
https://www.toyota.de/automobile/corolla/index.json I understand how .JSON works but, how is it possible to use that instead of say, .php or .html this is the first time I've seen anything like that.
We currently have a Users table in the database, this has quite a few columns in it. Around 50% of the columns are barely used in the system (only on one or two pages). We've been discussing amongst ourselves whether to split this table into two tables e.g. Users and UserSettings. Our thinking is also that we could the...
Sometimes it is pretty easy to find very natural concept to represent relationship, for example Person and Team can be connected by Membership, but occasionally it is not so easy and the concept might seem like so artificial. So is there any strategy to find or name these kind of relationships?
ISAs define things like instruction lengths and the instructions themselves and there are some things that I do not understand. Does the instruction length (the amount of bits) affect the amount of instructions that can be performed in a clock cycle? I have tried to do some research on what really determines the amou...
I'm trying to figure out how to create a Node.js/Express.js application that is a framework for hosting and running third-party code in my application, and what are the appropriate JavaScript/Node/Express terms for these concepts if they're different from other language I've used in the past (C++/C#/Java). In developin...