instruction stringlengths 34 36.1k |
|---|
I'm currently working on getting a good workflow going on, from development to a kubernetes deployment on cloud platform.
I'm pretty comfortable with various docker commands, but rewriting long commands each time is getting painful.
For example, for deploying docker images to google cloud I need to tag and push them ... |
I would like to write a data structure implementation in Java that uses caches as a core part of its functionality, and I would like the user to be able to provide their own cache implementations that implement a particular cache interface so they can test performance using various strategies (like LRU, LFU, MRU, etc.)... |
I work in a company that uses microservices. We have one particular service (let's call it Cart Service for example purposes) that manages some logic (storing carts, allowing other services to add and remove items from a given user's cart, etc). My team owns this service and multiple other critical paths (like Item Sea... |
I understand how service prividers in Laravel works and how to use them. But I'm not sure about how to keep clean code, specificaly in count of method parameters. For example I have this route:
Route::post('/user/user-rooms', '\Modules\Administration\User\Services\UserRooms@rooms')
Where class looks like this:
public ... |
Suppose that I have two services Person Service and Company Service and I want to maintain links between them for example a Person is linked to Company because he works there or he owns the company etc. So I will go ahead and create a database table like
PersonId, CompanyId, RelationType
Now the business logic can be... |
A system that sometimes will need to use a pretrained machine learning model.
That model is about 10Gb on disk,
and when loaded uses about 10Gb of RAM.
Loading it from disk takes a nontrivial amount of time,
so in general I wish to not do it too often.
Certainly not every function call against it.
Right now, I am using... |
We have a database with stores Outlets / Supermarkets (mainly in germany but other countries are also possible). We store some informations of this outlets / supermarkets like name, street, postalcode, city, geocodes (longitude
, latitude).
It is very important that one outlet is only once in the database.
From our c... |
I got an architectural problem here.
Let say there is an IShell. It mainly responsible to map user's commands (represented as a linux-like strings) to an appropriate IExecutable's.
Those executables are pretty various. Hence, there are different modules/assemblies/dlls (or how-the-hell-you-call-it): Module1, Module2, ... |
Please see the code below:
public sealed class UKCurrency : ICurrency
{
private static readonly int _decimalPlaces=2;
private static readonly decimal[] _denominations = new decimal[] {
50.00M, 20.00M, 10.00M,
5.00M, 2.00M, 1.00M,
0.50M, 0.2... |
I have dozens of Delphi (version 10.2.2 Tokyo) functions that I would like to be accessible from a C# MVC web project. These functions are mainly report queries that take a bunch of input parameters and output an array (or list) of records (or objects) as result.
I have full control on both code bases, Delphi and C#. W... |
Note: BLL = Business Logic Layer (can also mean your domain)
I'm trying to understand the onion architecture. It seems to me that it's actually the same thing as the layered architecture, only with the dependency inversion principle (DIP) applied. For example, this is the typical layered architecture (arrows represent ... |
I am working on EWS. A class is made to query mail box and read emails.
public class MailReader
{
private readonly ExchangeService _service;
private readonly PropertySet _propertySet;
private readonly IFolderSearch _folder;
private readonly IMailAttachmentAdapter _attachment;
private const int ... |
We currently have a work stream where we are splitting out a Monolith into microservices and there has been a debate as to how we will access and persist data.
To give you a good idea of how most of our apps are being set up, we have an app built strictly for the UI, a Web API it talks to and then another Web API that... |
I have a set of objects with different attributes; e.g. a set of cars with colors, brand etc. I choose subsets by virtue of a specific set of attributes.
Now I want to identify pairs of such subsets that differ only by one element.
Eg. say I have 4 cars:
A: Red, Ford
B: Red, Ford
C: Blue, Ford
D: Green, Volvo
Then the... |
Should I leave the else clause in a case like this where the compiler marks the else as redundant code and the else makes the code appear more logical --> better readable?
if (aCondition){
doStuff();
return someMethodResult();
}
else {
doOtherStuff();
return someOtherMethodResult();
}
or
if (aCondition... |
I've got a view that renders a menu. These menu items are dynamic, in that they only appear based on some conditions (authorization, for example).
I have two options:
Hard code the menu in the view with all the necessary conditionals
Structure and filter data outside of the view so the view is only responsible for dis... |
I'm working on a display library which in most cases works on a 2D plane but it has some components which display 2D projections of a 3D space.
This domain has the notion of Position, Size, Position3D and Size3D.
Position and Size are straightforward:
data class Position(val x: Int, val y: Int)
data class Size(val wid... |
I often see the term stale used to refer to data that is out of date, and fresh to describe data that is up to date. Both of those make sense to me.
But what do you call data that is not yet fresh, and has never been fresh?
The situation that made me ask this question is I'm working on an application that uses an ORM, ... |
We have a dependency to a third-party service which exposes a gigantic interface of which we only need like 3 methods. Additionally, the interface changes frequently...
I've decided to wrap the interface in a class in our project and only expose the methods that we need.
But I'm unsure how I should handle the return va... |
Let's say my user requests my ES/CQRS system to open a support ticket:
The controller sends an ask-support command, this command checks if the user has enough credit to do that, then emits an asked-support event.
Somewhere, a listener responsible for side-effects gets this event. It calls an external support API to op... |
where I currently work, there is a team that uses code-generation to generate slight variations of a program. I find this a little bit awkward. I can imagine using code generators that produce complex code for stuff that is usable in different projects, but using a code generator just for variations of an existing prog... |
I've been struggling with this issue for a while. Let's say you have a business application that has a rich domain and in one of the front-end views you show a list of open Orders. In this view you show things like that orderDate, customerName, totalAmount,... but the client also wants to see how many items are in the ... |
I've lately been involved with WPF and looked into MVVM. I understand that view model shouldn't be aware of view.
However, sometimes I come across situation where my initial instinct is to write property in view model something like public bool ShowDialog { get; private set; } or public bool ShowPopUp { get; private se... |
Context
In Clean Code, page 35, it says
This implies that the blocks within if statements, else statements,
while statements, and so on should be one line long. Probably that
line should be a function call. Not only does this keep the enclosing
function small, but it also adds documentary value because the
fu... |
I've encountered API that tell as being "restful" but then I see resources with verbs instead of reserving those said verbs to the METHOD.
Here's some (paths shortened so only the relevant method and path parts are shown):
POST /things/84/lock
POST /things/84/unlock
POST /things/84/edit
POST /things/prepend (Adding to... |
I do a lot of coding in python and got a lot of if conditions without an else statement so to say partial branches.
E.g.:
# if a certain kwarg was passed to a function call
if kwargs.get('a_option'):
# overwrite an entry in an already existing dict:
config['a_option'] = kwargs['a_option']
This always shows up ... |
I've created about a dozen services for a intranet. Now I've gotten to the point that these services are more coupled to each other than I'm comfortable with, and I've been having problems where once service can cause a few other service to degrade.
I've been working on a EDA design so that I can make these services d... |
I'm currently teaching myself event sourcing and have got the concept enough to start developing a dummy app in C# and EventStore. My app is an easy-to-understand bank account system.
If we model a bank account as a series of withdrawal and deposit events then we can easily calculate the account's current balance by ad... |
I'm meeting quite a challenge. We have an old grown software with mostly Delphi applications, and an underlying ISAM database server (ADS)1, used with a lot of free tables and manually programmed referencial integrity (if so at all).
Our deadline to move that mess to a modern RDBMS is 2020.
Some of the preferable DB Se... |
For many languages there are various tools which measure code coverage. But how exactly does this work?
I have some ideas, how this could work:
Do coverage tools just run the code in the debugger and step through it? Is some kind of static analysis used? Or do some tools just inject some markers into the source code,... |
I'm reading Applying UML and Patterns and trying to match the OOA&D principles in there to a project I've worked on. It is kind of a retroactive learning exercise.
The basic question I'm trying to answer is do I have the correct understanding of how to find the actors in this domain? Have I found them correctly?
The pr... |
I need to make a web app which provides the feature to install/uninstall
plugins. Think of something like Eclipse IDE like software. The only difference
is you cannot restart it like Eclipse to apply changes. I guess I can say, it would be similar to Wordpress.
I thought of am implementing this using OSGi as follows:
W... |
This article states
However, this design does run into problems with some of the methods of the MutableSequence ABC. Most notably, insert and
__ delitem __ can't operate on position 0, because you can't change the head of the list when the only reference you have is to the head of
the list.
If we have a reference... |
I've been looking at ways to let my app's users write plugins for it. However, to give them more options, I decided to implement a polyglot plugin system.
From the engineering perspective there are multiple ways to do this.
Transpiling: Not many libraries that can reliably do this.
Bindings: Types can be a pain.
Usin... |
Let's say I have a mobile client for answering questions and then purchasing a widget. For example, I might have 10 screens from my UI with about 8 questions per screen. Imagine there is a screen for first name, last name data, 'create personal information' is basically the operation/service call.
With REST, JSON ov... |
I have seen this pattern that allows web pages to interact with local system resources through a HTTP interface and I have a couple questions about it:
What is this pattern called?
What recommendations exist for implementing this pattern?
What are the security implications?
Basically, the requirement is to access a l... |
So in networking class they taught us the OSI model, TCP, CDMA, congestion, frames, etc.
What I would like to know if standards that have been around for 20-30 years like TCP, are burnt into today's hardware, or can someone come up with say TCPX, write the code, deploy it to two machines on the network and use that pro... |
Who writes functional specification in a software company ? Given a software company typically comprises of Software Engineers, Engineering Managers, Product managers and Directors?
|
I want to implement the "shopping cart" feature on my website. Both anonymous/unauthenticated and authenticated can have it.
While it's clear how to implement it for an authenticated user, it's not completely clear for the anonymous/unauthenticated user case. I believe that I'll have to create a long id, such as GUID ... |
Speaking of php. It doesn't really have its own runtime in compare to python, ruby or go. Php is jsut a text preprocessor.
What exactly does it mean by, Php doesn't have runtime?
|
The big image is catalog or ad blocks that comes from catalog table. And small images are the actual products block that comes from product table.
There may be more products and more catalog. attached image is just a layout sample.
Please refer the below image link for layout.
https://i.stack.imgur.com/f4KxN.png
|
I have a set of types that can be customized by formatters. A formatter is a function object defined as Func<string, string, string>. Client of a library may than choose to implement FormattedLoggerBase with one of formatters provided or write new one.
public abstract class FormattedLoggerBase : LoggerBase
{
... |
Studying Inter Processes Communication in Operating System, I've discovered that asynchronous communication can be built on top of synchronous communication. But, it's not clear to me how can it be done.
Can you explain to me ? :)
|
In one of my projects, I had to name some variables and functions that belong to the person using my app. I named them userCard, getUserInventory() and so on. I named them like that cause there were variables and functions that belonged to other persons, like opponentCard, getAllyInventory() etc.
Now, I have a model cl... |
Let's say you have a permission system with which you can specify things like: user U is a member of group A, which is a subgroup of group B, which is a subgroup of group C, and all members of group C have access to object O. Then, you can query the system like: "does user U have access to object O"?
As far as I can t... |
Recently my team has inherited a code-base with an interesting problem.
The system keeps historical records by having multiple listeners on the same event. These listeners execute serially, so if we have listener A, B, and C, B would wait for A to finish first before C and so-on.
Each listener updates a separate table... |
Currently we are debating over securing our multiple micro-services.
The major concern is that the JWT token provided to us will expire before the call is finished. (This is in the synchronous design)
Here are three proposals:
Client App has an 'ensure(int minutes)' method before lengthy calls, calling token provider ... |
I'm trying to figure out is there a common name for object's interface if our intent is to show that this group of objects has date of creation and tracked dated of last modification. It is an entity in DB.
Have thought about IHasModificationDate and ITrackable. But I'm sure that other programmers outside of the soluti... |
My team needs to design an API which sends objects to a queue in the cloud and retrieves objects from it. The data is inserted into the queue as byte[].
We have 2 ideas until now which I would love to hear your notes/ideas about them:
First version:
public void push(String object)
public String retrieve()
Notes: To s... |
I'm struggling a little bit with Domain Driven Design because there are so many names and concepts to grasp.
Today it striked me to know what is exactly the difference between an 'application service' and an 'use case'. Are they the same thing?
|
I'm working on an MVVM project and trying to preserve separation of concerns. Our current architecture has an entity framework model and MVVM light view and viewmodel projects. I'm working ViewModel first so I'm passing those around with a datatemplate in the view project to get the proper view.
Having to type chec... |
The application I'm developing requires that some data is obtained through different channels. As this is a network process, I have decided to use async programming.
I have designed the following interface to represent all the possible channels:
public interface IMyDataChannel
{
Task<MyData> GetMyDataAsync(/* param... |
Developers create scripts to help in their work. For example, to run Maven with certain parameters, to kill unneeded background tasks that crop up in development, or to connect to a certain server. The scripts are not core build scripts nor are they used in our Continuous Integration server.
What is the best way to man... |
Please see the class below:
public class Customer
{
private readonly IList<Order> _orders = new List<Order>();
public string FirstName { get; set; }
public string LastName { get; set; }
public string Province { get; set; }
public IEnumerable<Order> Orders { get { return _ord... |
I currently have a website, made of about 20 micro-services and a (still too large) main monolithic web application. The monolith and multiple micro-services each run queries to the same database, each time having to deal with login to the DB and formatting/running the queries.
I may switch our databases from SQL to N... |
When you use the concept of polymorphism you create a class hierarchy and using parents reference you call the interface functions without knowing which specific type has the object. This is great. Example:
You have collection of animals and you call on all animals function eat and you don't care if it is a dog eating ... |
We are developing an application where providers can offer their products and consumers can buy them (sort of marketplace). We try to apply DDD concepts into our model design and the implementation follows a microservices style. This implies that the data belongs to a Bounded Context (BC) and only the microservices wit... |
In the Wikipedia article for “tracing garbage collection”, the following claim is made:
...most modern tracing garbage collectors implement some variant of the tri-color marking abstraction
In this abstraction, objects are grouped into three sets: white, black, and grey. The basic tracing algorithm enumerates all the... |
Consider the following command-line program manage-id. It does these things:
manage-id list (list all usernames and user-ids)
manage-id show <username> (shows username's id)
manage-id clear <username> (erases username's id)
manage-id set <username> <user-id> (sets usernames... |
I'm looking for information on the best approach to message validation in asynchronous-messaging-based services (i.e. services that pull messages from some sort of message queue or broker, rather than providing an HTTP-based API or something similarly request-response oriented).
In an HTTP API, if the message is invali... |
I am designing a system to receive data from various types of sensors, and convert and then persist it to be used by various front-end and analytics services later.
I'm trying to design every service to be as independent as possible, but I'm having some trouble. The team has decided on a DTO we would like to use. The o... |
I am writing gui application. I want to implement following structure:
project tree with nodes of different type and behavior (i.e. when right clicking or selecting there can be different menu options)
Editor window, which can be dynamically splitted vertically and horisontally, to add more edit areas. Each edit are... |
What kind of NoSql data modelling is best suitable for the following requirement?
This can be visualised (NoSQL-Document) as a Collection of Records where each Record contains nested Documents.The nested document entities at different levels are either flat or tree structure based. A Record is structurally a single en... |
I'm writing a reusable library, and I'm looking for a way to handle the exceptions that might occur during the processing. For example, I have the following class:
public interface IObjectFetcher
{
public IObject GetObject(int objectId);
}
public class WidgetFetcher : IObjectFetcher
{
public IObject GetObject(... |
Note: I use term "resource" in opposition to memory here, resource here is file, socket, etc.
Is there a language implementation that uses M&S GC (but not necessarily only that kind ¹) that is able to automatically free the resources (like file handles)? If yes, how it is done?
By automatically I mean that user can mar... |
I am writting a module where i am creating a rate for a list of product, and the rate for the product are assigned to different Store.
The rate can be created in a group of Store, with Multiple Store, and Individual Store.
As shown in the image Below.
a. Group of Store
A Store group is selected from the list of group.... |
By theory please correct me if I am wrong, it says that an int can take upto max 4 bits in case of number 9.
I haven't coded it low level languages but I assume that the datatype int in c and python shouldn't be different.
I want to know what is the reason that in Python an int is taking 24 bytes
Also if someone can e... |
The most obvious criteria for me is for component re-usability, as well as internal state management but aside from that are there are any other good reasons?
For instance, I could have a component called ArticleFeed.js. Within ArticleFeed.js I could have a child component known as ArticleFeedItem.js OR I could just ha... |
I don't have a particular coding problem on hand this is just an excercise to improve my thought process.
Few months back I started learning about functional programming( mostly in R) and I fell in love with it.
Once in a while I try to think of problems that might be(correction: that I might find) difficult to solve i... |
Under the REST architecture principles, a RESTful application should be stateless, therefore each time I invoke an ASP.NET 4 REST service (with GET verb) that pulls tens of thousands of records, the REST service paginates them with in chunks of 10 (with OData v4), which makes the UI lightweight because it only loads 1... |
This question has been asked quite a few times on StackOverflow and I would like to get an understanding of the concepts and process rather than directly solve a problem. I found the following post where the explanation was nicely detailed but have some follow up questions which I hope someone can elaborate on.
video s... |
What is the best practice for REST API call from and device (Android, iOS). I am getting extra parameters/fields in JSON response, while calling an API. Throughout the the application there are several API which contains extra params in it.
Should I ignore the extra params or I rectify my API for less needed fields. Wh... |
We're using a similar concept to Event Sourcing to store the data/actions of a collaborative system we have running.
The system has some 2-3k users that use it daily and it's growing.
As time goes by, the codebase evolves and the data we already have stored needs to be updated to match newer formats. This is a rare sce... |
I have several objects that implement an interface, and several repositories that perform CRUD operations these objects.
I'm given a GUID and I don't know which class the object is, but it's in one of them, and am using the repository to get the object by its GUID.
The repos return different types.
class Obj1 : IInterf... |
There are several posts and other contents in the internet that claims against naming classes ending with "er" (like manager, controller, helper...). I personally agree with that, but what alternative names could be given to MVC controllers in the scope of web development? I came up with "entry points" or "end points... |
What would be the right way, according to the Middle-ware paradigm/design pattern to transfer resources (like connections to some IO devices).
It is not part of the Request, and it is definitely not part of the Response.
Is there a third object each Middleware step transfers to the next step in line?
The specifics of... |
We use Selenium webdriver + SpecFlow for testing our Web application.
For some functionality, everything is clear.
But imagine the situation: some questions arrive to Web user from external system he may answer. The test should "test" if the user can see those questions in appropriate view and successfully submit some ... |
In Android Framework there is a string.xml file that houses all the strings for the application.
This allows for easier re-use and possible internationalization. My question is, is there any precedent/good reason of doing this in a web application?
|
What are the differences between a demo and a prototype in software engineering?
My research taught me that a prototype is typically the minimum viable software needed to allow users to test its functionality.
Please provide an example to clarify the differences.
|
I am trying to refactor a large and complex application to use DDD principles as and when I get time.
I have a class, which is completely isolated from the domain (it is only used by an application service) but part of the ubiquitous language. It looks like this (an old version of it):
public class CurrencyCalculato... |
Let's take two simple Rails models, Post and PostRevision.
class Post < ApplicationRecord
# Attribute: Status (ex: draft, public, private, deleted)
# Attribute: Views
# An owner, likely a belongs_to relation. Perhaps a has_many relation.
has_many :post_revisions
validates :post_revisions, :presence => true
... |
Context
Suppose I program a blockchain which doesn't require proof-of-work and deploy it on 3 servers A, B and C.
Now suppose server A and B receive requests to insert a new block with some data in the blockchain. Both A and B modify their local copies of blockchain. Before the modifications, the local copies of the bl... |
I have an ASP.NET Core 1.1 application which uses dependency injection and is splitted in 3 layers (web, business logic and data access).
I'd like to access to some values of the configuration file in some methods of the business logic layer. Which way would be more correct to keep a clean architecture?
Pass the confi... |
I have a resource that can be updated in two different ways. I will try to explain using an example.
Lets say that each Person is assigned a Task. So to update the task, I have
PUT /people/{personId}/task
and I send the task details in the body.
Now I need another endpoint to update the task assigned to a person. Thi... |
My coding style for nested function calls is the following:
var result_h1 = H1(b1);
var result_h2 = H2(b2);
var result_g1 = G1(result_h1, result_h2);
var result_g2 = G2(c1);
var a = F(result_g1, result_g2);
I have recently changed to a department where the following coding style is very much in use:
var a = F(G1(H1(b1... |
You know how it goes: there is some small repetitive task for which you found a way to quickly automate 95% of the work. You create a script, run it, manually fix the output, and you're done. Of course you don't commit the script, as it doesn't match the company quality requirements (it doesn't have documentation, nor ... |
I'm working on an application which contains an element that needs to make several http calls in a set order, to perform an action successfully. (Interfacing with an external system's API.)
We have written code that is functional, but struggled when trying to write appropriate unit tests to cover it (not least the HTT... |
I have an app with an optional login where some functionality requires the user to login.
When checking if the user is logged in I use a framework that runs an async function that requests an access token from the keychain or our server (depending on if the token needs refreshing) with a completion block telling us wha... |
From a REST API, we write to the database. We want to store who was the person that triggered this change. We have this information at the controller layer. The saving happens at the repository layer (We use spring boot, and have a service layer in between for business logic).
How can I stop leaking the auditing inform... |
Maybe I'm not the first to ask this, but I've searched up and down the stack and I am yet to get an answer to my question. I have learnt CSS, and I also have a basic idea of the C programming language. While learning C, the syntaxes and the way it is coded strongly reminds me of CSS.
For example:
Comments both in C an... |
This question follows on from my other question here: How does an isolated class (or group of isolated classes) fit into a Domain Model?
I have looked at a few domain models online:
https://github.com/vkhorikov/DddInAction
https://github.com/nhibernate/nhibernate-core/tree/master/src/NHibernate.DomainModel
https://git... |
I understand the rationale behind why most of the HTML character Entities were created, but I don't understand the purpose behind the ampersand HTML entity. & contains more bits than a & symbol, and it even has the & inside it already!
Why was it decided that ampersands should be encoded in the format that require... |
Among other things, the CQRS has a rule that each of the methods has one responsibility. So we can't have this in the model:
public class Store {
public Item getOrCreateItem(int id)
{
//logic
}
//....
}
and this in the controller:
Store store = new Store();
Item item = store.getItem(1);
We m... |
I have a general question pertaining to Cyclomatic Complexity. Please have a look at the attached source code:
private void downShift(int index)
{
// index of "child", which will be either index * 2 or index * 2 + 1
int childIndex;
// temp storage for item at index where shifting begins
Comparable temp... |
I have a huge set of over a million numbers of variable lengths.
['773', '2267', '8957251', '170597519', '373590109', '982451707', '999999937', ......]
Now given a bunch of digits, say 3 and 7, I intend to create a subset of all numbers which contain those digits. That is:
['773', '373590109', '999999937', ......]
Th... |
I am trying to implement clean architecture (https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html) on an Android app.
As an example, let's say that all the app does is monitors a user's CPU temp and displays a hourly and daily average. Data is stored on the device and periodically downsampled. The... |
Java provides methods for saving data permanently. An object that has to be saved has to implement the interface Serializable. But there is one problem with Java's object serialization: The objects can not be changed. If I open such a file, i see some cryptic symbols. But sometimes I also want to change the data outsid... |
Suppose I have an application that accepts an arbitrary stream of objects. Some of those objects appear multiple times in this stream. The job of my application is to filter out those duplicate objects from the stream and pass a duplicate-free version of the stream to the next application. This is usually trivial, but ... |
Some time ago I had to code review a unit-test fixture like this one (C# code):
public class ServiceFixture : Service
{
[Fact]
public void Test_DoSomething()
{
Assert(DoSomething(), SomeExpectedResult);
}
}
So Service is the SUT, the class under test, and ServiceFixture is the test fixture. And... |
I have member function that looks like:
Point find_the_special_point(Image img);
However, this function may fail to find the point (for example the img does not contain a special point at all).
What is the right way to make the function return in some way that the point was not found?
I thought of some solutions but n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.