instruction stringlengths 34 36.1k |
|---|
I have been using git for a while now primarily on CLi. I am the only person
working on this project so far. I just have 1 master branch and 1 production
branch. The production branch is named such that all tests in that branch
pass. I work directly on the master branch.
I had a issue recently, which prompted me to thi... |
From what I can tell from Scala and Hack-
Mixins:
Can have state (ie. instance properties)
Can only provide concrete methods
Can have constructors, that are called in the same order that their classes were mixed in
If A mixes in B and C, A instanceof B == false and A instanceof C == false
Traits:
Can only provide me... |
I have many substrings(2-5 words each) which I would like to search in some text of about 40-50 words length. What is the most efficient way to flag matching substrings.
Currently I am simply using:
for substring in substrings:
if substring in fullText:
return True
substrings - the list of strings to be searc... |
I'm creating audit tables to track changes made to some of my crucial tables and I'm wondering whether there's a point to history rows having their own id. Here's how my interfaces look like:
public interface ITrackedDbEntity : IDbEntity
{
Guid GUID { get; } //pk, unique
int Id { get; set; } //unique, not pk
... |
I am just designing my application and I am not sure if I understand SOLID and OOP correctly. Classes should do 1 thing and do it well but from the other hand they should represent real objects we work with.
In my case I do a feature extraction on a dataset and then I do a machine learning analysis. I assume that I co... |
I have a class called Book with fields such as title, type etc. I also have a class called Library that manages books.
Library has methods that:
Add a copy of a book on a shelf
Move a copy of a book from a shelf to another
How Can I manage the fact of the copy of the book?
One solution is create a subclass of Book,... |
I'm trying to improve my skills in planning out clean, modular projects with minimal coupling. Is it best to keep objects as generic as possible?
If so, are there any pitfalls I should try and avoid when designing architecture?
|
Note that I cannot use static inheritance due to language limitations (Java).
There is a general Building class. Each instance of Building has properties that exist regardless of instance variables (such as width, length, max level, BASE damage). There are numerous types of buildings, such as resource and defensive, an... |
I am looking to create a random username based on a set of existing phrases plus an integer since there can be multiple users with the same phrase. For now lets assume there's 12 phrases such as AnonymousPotato, so a user who signs up could randomly receive AnonymousPotato12345 as a unique username. The user would be s... |
I am writing some code that really smells but I can't figure out exactly why.
I have documents that exist in multiple languages. I want to be able to serve a document in its requested language and be able to switch it out for other languages when requested. On my database the documents are separate entries with identic... |
As far as I know both the regular and enterprise developer programs both have a 100 iPhone limit for development. I don't mean distributing the app for testing where the limit is higher, but for plugging the phone in for debugging with Xcode.
How do larger companies deal with this limit? If they have multiple teams tha... |
I've written a few things using .NET Core and like it a lot. So far, I have always used Visual Studio Code (which I think is very good and getting better all the time) and have enjoyed being able to pick up work on a Mac. I've been using Visual Studio less and less as I do more using .NET Core.
However, last night, I a... |
I would like know opinions about the next sentence:
"In a object oriented static typed language you should declare variables and parameters as broad as possible and return types as narrow as possible"
In some extreme this afirmation could produce this code:
interface anyInterface<T> {
Collection<T> getCollection()... |
Are there objective, supportable software-engineering arguments for or against modifying the values of by-value parameters in the body of a function?
A recurring spat (mostly in good fun) on my team is whether or not parameters passed by value should be modified. A couple members of the team are adamant that parameters... |
In refactoring some code I found a helper method get_records_from_file that has a complex return signature:
class RecordDefinition:
def __init__(self):
self.foo = None
self.bar = None
def get_records_from_file(file_name) -> Dict[int, List[Dict[str, RecordDefinition]]]:
...
After some inspection I... |
Here is a diagram of how our source control setup is configured.
The issue with this setup is how we handle various customers. I would really like to use a different approach than copying the entire baseline for each of our customers. I think further down the road this will become a major problem to maintain.
How can ... |
Assuming I have the following (over-simplified) class structure:
class Base
{
public:
Base(int valueForFoo) : foo(valueForFoo) { };
virtual ~Base() = 0;
int doThings() { return foo; };
int doOtherThings() { return 42; };
protected:
int foo;
}
class BarDerived : public Base
{
public:
BarD... |
We are using version in following format:
Major.Minor.Bugfix.Test
Development for upcoming release is going on in the trunk. When enough features are done we are creating a new release branch: 1.1, 1.2 and so on.
After branch is created there is a continuous "stabilizing" process, producing test versions of branches:... |
We have some fields (age, visit type, insurance type, city) and some rules:
Some doctors that define weekly schedule template like as:
Doctor D1 works on Monday 7-9 pm , Thursday 7-9 pm.
Some type of Visit Type like as:
Doctor D1 accept Follow up- Laser- Rhinoplasty.
Some type of counters rule in specific time r... |
I'm midway through Eric Evans' DDD book but don't think this question would be answered in the book.
If an application has its own complicated concepts different from the underlying domain, can we create another domain model for representing the application too?
An example would make it clear. Say, the core domain of a... |
The "Three Questions" for Scrum dailies sound to me like a perfect instruction, to waste 15 minutes with useless status reporting:
What have you completed since the last meeting?
What do you plan to complete by the next meeting?
(impediments...)
It often goes in the way of: "Yesterday I did task X, today I will work... |
I'm having troubles with using the right workflow with TDD. Some people say we should design before writing any code, some say we should make a test, make it pass, then refactor the code and that should help our thinking to find the right design.
But everyone say you should have 10 times more unit tests than integrati... |
We had a contractor visit recently who questioned our methodology of structuring projects. Please note that I am specifically referring to the directory structure. He suggested using the Microsoft guidelines. I thought I would be able to Google "Microsoft guidelines .NET project directory structure" and find somethi... |
The date format should support different timezone and Daylight saving issues.
|
For a match I have certain number of players, certain number of groups (players and groups are aliquot) and certain number of rounds to be played (players are reshuffled every round). Ideally, I'd like players to meet new people every round.
It seems like a common problem that had to be solved many times before, If I o... |
I had a recent code review that gave me some slightly surprising feedback. It was in an instantiable service class that had a number of fully encapsulated private methods. In other words, methods that didn't reference any higher level functions or variables. For a trivial example:
private decimal IncreaseByPercent(deci... |
I have a CQRS system in development that passes the Command to a CommandHandler, which gets an Aggregate from a Repository, and calls a method with the properties of the Command (converted to ValueObjects).
The method then creates the Event internally and registers it in a hash object to be collected and persisted late... |
i’d like to push discussion on the same named thread again.
I also use auto increment primary keys as foreign keys - mostly for code tables. Every row also has a code for identifying entries for users (like ProductKey).
Everything works fine till I need a validity period for entries in code tables.
e.g. every Client ha... |
I have a library with several layers. The library is a hardware API and has several threads. The application that is using it has no direct user interaction the UI is for display only. I needed a way to tell the user if there was an error and what it was. So I created an Error Event that passes a message up the layers.... |
To clarify, as I'm not entirely sure how to summarise in the title.
I have a redis cluster and a redis-backed scheduler (similar to sidekiq/resque, etc).
My redis cluster has a master and a couple of slaves. I insert a job onto the master and that is replicated onto the slaves.
I have 4 workers listening on these slave... |
As I was working on upgrading deprecated ereg_replace() statements in an e-cart sollution I was suddenly puzzled by questions regarding how to handle the submitted data I was working with.
I was working with the add to card function, which from the backend perspective recieves an integer for how many products to add to... |
Suppose I am designing a web application and also building a Web API with authentication via Kerberos/NTLM. The Web API is first for my app, but I imagine I want to make it general-purpose. My instinct is to create the Web API as its own separate solution, and then consume it with XHR requests in my web app. So perh... |
I'm writing what I might refer to as a Maven project dependency management process for a project I work on. Whenever a developer wants or needs to change the version number of an existing Maven dependency or add one or more new dependencies, they must follow the process.
So far, I've identified four stages:
Confirmati... |
Suppose that you are in the phase of requirement elicitation (discovery). You have
already interviewed your customers and created use case models to discover as many
requirements as you can. However, you strongly suspect that there are some implicit
requirements (e.g., domain knowledge that is so familiar to cus... |
So I've done a good job separating the DAL from the BLL. I use repositories for each aggregate root. The issue I'm having is database concurrency with IDs in the domain.
I don't want to use the surrogate key in the domain layer (e.g. GUID). So the aggregate root I have now is a Journal and that Journal has a list of... |
I have a great deal of 'dirty' data pulled from an API request.
Before database insertion, I clean out a lot of line feeds and regex out values such as height and width from item descriptions.
This is my first large project as a software engineer, and I would like to leave something coherent for future developers.
He... |
I have two parallel hierarchies:
B and C implement interface A
D and E extend the abstract class F
I want to be able to do: F f = createObject(A a)
where createObject should follow the behaviour:
F f createObject(A a){
if (a instanceof B)
return new D(a)
else if (a instanceof C)
return new E(a)... |
I'm working on a project with a MVP architecture.
My program revolve around forms that give rights to people.
There are X differents forms depending on profiles ( so there are X differents profiles)
I have an abstract class which we will call BasicFormClass.
Each forms has a presentation that inherits from BasicFormCla... |
I'm in the middle of refactoring a project (in C++11) and I'm struggling with a decision is it good to change huge enum with about 100 record to separate classes.
This enum is used in about 4 places in code in 4 different functions with huge switch statements. For every enum, the record is some code in every function.
... |
I'm testing that a function does what expected on a list. So I want to test
f(null) -> null
f(empty) -> empty
f(list with one element) -> list with one element
f(list with 2+ elements) -> list with the same number of elements, doing what expected
In order to do so, What is the best approach?
Testing all the cases in ... |
Going through Effective Java, Joshua Bloch states that the drawback of using JavaBeans pattern is that an object may be in an inconsistent state partway through the construction and with JavaBeans pattern, we cannot make our class immutable. I have understood this much.
He also says that we can reduce these drawbacks b... |
Where I work, we use a language for our desktop software development (Delphi) and an other for web apps (asp.net/c#). My bosses want me to implement a feature on a website but they ask me to develop it in Delphi because they think they might need it for one of our software someday.
When the same situation happened in ... |
I do not have production experience with docker and have several questions regarding a local registry:
A dockerfile is the description (=recipe) of how an image is built(=cooked, e.g. FROM alpine:3.5)
If the image on my Docker Host isn't present, it is pulled from a docker registry. As far as I know is Dockerhub regar... |
In my understanding, evolutionary architecture boils down to making architecture easy to modify. Now architecture is often defined as the things that you should get right early because they will be hard to change later.
How does this fit together? Is there any difference between evolutionary architecture and simply min... |
Note: I am note sure how to phrase the title
This is pseudo code of my Project that I am working on. For conciseness I have left out some details.
I have a 2 types of Consumer classes. One is inherited from the other and does a some extra things.
Consumer has a thread that runs a queue of tasks.
I have a IProducer that... |
Assume
You have some POJO Animal like
public class Animal { // some fields }
You have some enum AnimalType like
public enum AnimalType { // some animal types }
You have some method that given an Animal returns an AnimalType with signature
public AnimalType getAnimalType(Animal animal);
Finally, you have some inf... |
I have seen it done both ways, but I have never seen any discussion around which is the more "right" way.
Say you have a entity that has children relationships to other entities. The children can't exist without the parent, so does it make more sense to make on service that handles the CRUD of the parent AND the child... |
So, there is a workflow I feel needs to exist. It may already exist, and I don't know about it.
Consider the Linux command line workflow, the "motto" of Linux, more or less. You have a bunch of small programs, accepting input and producing output. Each does one thing well, and the user puts them together to do compl... |
I have a code base that contains several different instances of the following pattern, the key point of which is that the concrete type of the class is decided at run time based on a string from a config file.
class Foo {
public:
virtual void bar() = 0;
};
class AFoo : Foo {
public:
void bar() {
// ...... |
So one thing I didn't really think about when designing this personal finance application was WHEN (not HOW) to persist the data. I'm using DDD, a 4-tier architecture, and EF.
It struck me when I added a new Transaction, Account, etc. that it's immediately saved to the DB. However, this is not how most desktop applic... |
This isn't so much as a specific code review, but a concept review when converting a class diagram to code and then eventually a database, in Python. I know how to add things in to a database, but I have only ever done this directly with SQL from forms and not from classes, (which I believe is called ORM)
I have the fo... |
In our user-rights management system we basically follow "CRUD", where at each incoming request the user is checked against his rights, and see if he has create, read update or destroy rights for the data he wishes to access.
This system is created by my predecessor, however I'm constantly in doubt if this is the right... |
We've built a class that allows you to easily draw stuff on a <canvas> element.
That class is called Canvas. I've encapsulated the <canvas> element and the class itself in a WebComponent, called <paper-canvas>.
<paper-canvas>
<canvas id="#canvas"></canvas>
<paper-canvas>
<script>
class PaperCanvas {
constructo... |
I've recently caught an odd behaviour in my own coding: At some point in the last year I began creating protected static methods to implement the logic of my public methods, ensuring that the protected static version contains all of the logic, but is not affected by state.
e.g.
class Demo
{
string someAttribute;
... |
I am writing automated test cases in Visual Studio 2017 test frame work. I am testing the ‘create user’ part of a web API. A user needs to be created with a unique email address. Once a user is created they cannot be deleted.
Is there way to write automated (run on check-in) test cases, that need unique input data for... |
I am trying to understand behind the curtain scenes of Javascript and kind of stuck in understanding the creation of built in objects, specially Object and Function and the relation between them.
When I read that all the built in objects like Array, String etc are extension (inherited) from Object I assumed that Object... |
A common pattern in database design is to append dynamic columns to a table with a design like so:
create table MasterTable
(
Id int not null primary key
, Name nvarchar(64) not null unique
, SomeColumn2 int not null
)
create table MasterTableAdditionalColumn
(
Id int not null primary key
, Colum... |
Where I work we've got wallets with transactions (i.e. every transaction belongs to a single wallet). Currently we're working on an addition of transfers between wallets. As a part of this, a new Transfer concept has been added to the ubiquitous language dictionary.
One functional requirement is to give users the optio... |
I see questions similar to this with regards to parameter names that match properties on the class, but I can't find anything regarding using a parameter name that is the same as the parameter type name except for casing in C#. It doesn't seem to be a violation that I can find, but is it considered bad practice? For ex... |
My question regards the best practice / industry standards to prevent rogue users/admins from directly logging into the database console and updating sensitive information such as financial info / balances, etc as opposed to using the software which would otherwise validate the user's actions.
I ask this because the so... |
My application consist of a web client (implemented in angular or reach) and rest web service, both hosted on different servers. For implementing the OAuth2.0 login for Google, Facebook etc., should i implement the same on client side or server side and why?
|
Maybe anti-pattern is a better word for this question. I do not know, but I mean a violation of DRY. Id like to reuse a partial view, and I can, but that partial view has other things in it I don't want in my div I'm populating.
For example,
I have a page with a name. I can browse to a view and it shows me informati... |
I have a system i've written on paper and am trying to write this into C# in a easy to use manner.
I want a series of connected waypoints (where by waypoints can be connected to any number of other waypoints).
But waypoints can either just be an arbritrary point along the path or an actual object in the system with som... |
I have a loader class that executes data loading functions at boot-time for my application to give me test data.
The idea is pretty simple, I'm reading in XML data, using JaxB to turn it into a POJO and then persisting the POJO using JPA repo.
Here is my code (pretty small):
Looking at the parseFile method, I create a... |
I have a project that is sufficiently large in size that I can't keep every aspect in my head any more. I'm dealing with a number of classes and functions in it, and I'm passing data around.
With time I noticed that I kept getting errors, because I forgot what precise form the data has to have when I pass it to differe... |
I was hoping to get some advice from you folks on my table design methodologies (specifically in MS SQL if that matters).
Let me start by showing a couple of example tables that I might have in a typical application:
EntityType
-----------
EntityTypeID int identity (PK)
Token varchar(10) (Nonclustered IDX, UNIQUE const... |
To keep classes decoupled I'm using the Mediator Pattern like so:
class Mediator {
constructor(canvas, selectionBox, undoManager) {
this.canvas = canvas
this.selectionBox = selectionBox
this.undoManager = undoManager
}
addText(text) {
this.canvas.addText(text)
this.undoManager.captureUndo()
... |
I am implementing a custom ILogger (interface for logging).
I have succesfully developed implementations of it with some famous loggers like Serilog or Log4Net.
Now I want to create a memory logger that stores all the logs inside a List (memory).
Since the List will only exist in the MemoryLogger:ILogger , I think th... |
We have a bunch of services which are using AWS Kinesis to communicate via events. We have different events such as MasterDataUpdatedEvent, PriceUpdatedEvent or AvailabilityChangedEvent.
Currently, we are using a dedicated stream per event:
MasterDataUpdatedEvents go to master-data-updated-event-stream
PriceUpdatedEve... |
I'm only a student, so forgive me if my understanding is poor or my ideas poorly expressed.
I want to create a purely client-side browser application that works with the user's Dropbox account. They would go to the page, click 'Connect My Dropbox', grant permission, get the access token back, and store it in local stor... |
I'm trying to determine the best application and database architecture for a project I am working on.
The idea is that there will be multiple, separate applications that will all share a few tables like a User and an Employee table. Each Application will have a web portion (which may require an API, depending if server... |
For the purpose of writing a library, I found to be nice to add types to some well known namespace.
Example:
I've written a couple of extension methods for BinaryWriter and naturally put them in System.IO namespace.
Pros:
they're readily visible and usable
I do not end up rewriting it and shortly after discover it was... |
I'm on a new CRM dev team. And simply put, I haven't seen sprint execution such a mess in my whole professional career.
I have a deployment plan moving forward. I have an idea how I want continuous testing done in our test environment. However, I am torn on how often to push to test; because some sprints have alot of... |
Suppose I have created an application that makes remote connections and does stuff, how does an anti-virus/anti-malware program decide if my app is harmful?
I know there is a signature they check for to identify a program as either good or bad but it seems to me that would result in a lot of false positives because a l... |
So I keep track of all my finances using an Excel document (and have been doing this for many years) and it's become quite a pain. So for a fun side-project I want to implement something to handle it for me.
Initially I set out using Entity Framework with a LocalDB to handle the backend for me. But as I continually r... |
If I have three entities like this:
WorkingGroup
WorkingTime
Shift
The WorkingGroup has one or more workingTime
public class WorkingGroup
{
public WorkingGroup()
{
IsActive = true;
IsDefault = false;
WorkingTimes = new List<WorkingTime>();
}
priv... |
There's a 1st software module (s1) that generates data and then there's one or more software modules (s2, s3) that will receive that data (objects), based on pre configured actions that define the type of data to transmit.
A middleware (api) needs to get the data from s1 and convert it to s2 or s3 structure depending o... |
According to Wikipedia, Functional programming languages, that are Declarative, they disallow side effects. Declarative programming in general, attempts to minimize or eliminate side effects.
Also, according to Wikipedia, a side effect is related to state changes. So, Functional programming languages, in that sense, t... |
So, from my understanding, Html Helpers are supposed to be for single elements or small snippets of html. However, I'm not really sure why I think this, or how I came to abide by the practice. I couldn't find anything from Microsoft that covers this topic either.
The reason I ask is that recently I've been asked to bui... |
I am developing the UI of an e-commerce. Actually it is the checkout page only.
The entrance URL looks like this:
myEcomerce.com/{orderGuid}
On load The ui takes the orderGuid as parameter to call the API and get the details. In other words, UI call getOrderDetails passing the orderGuid.
My main concern is in relation... |
Using .Net web api
I have a web page that renders a collection of items depending on filter values applied via an ajax call to an api endpoint.
The items are paged so that if the user scrolls to the bottom of a page then another ajax call to the api with the required page number of the next set of items is made.
I have... |
I've been researching microservice architectures trying to get a high level overview of all the pros and cons, whens and whys, etc. A lot of the information I'm reading/watching is coming from ThoughtWorks (Martin Fowler, Neal Ford, et al).
Most of Martin Fowler's work on the subject is a few years old, when Microserv... |
I have been reading Alistair Cockburn's article on Hexagonal Architecture. One question that occurs to me, is how to handle situations where there are database concurrency issues.
An obvious example is a situation where an entity is retrieved from the repository, has an integer attribute incremented, and then is saved ... |
As far as I got it correctly, as a result of Rice's theorem, the equivalence of two programs is generally not decidable.
Nevertheless, there exists a wide variety of testing and debugging techniques, which do change the program for their purpose - actually, I can barely think of a technique that does not. So in fact, y... |
I believe the concept of DevOps is the single person handling all the activities of a given requirement.
1) Understanding the requirement/problem
2) Come up with logic to solve the problem
3) Write code for the logic
4) Test the developed feature
5) Deploy it
6) Maintain it
Does this mean "Division of Labour" is ... |
I am writing my first state diagram for an approvals matrix and I am stuck. An Order in our system will go through a number of states and transitions for approval:
States
Start (state)
(submit() transition)
Awaiting Approval (state)
(approve() transition)
Awaiting Approval (state)
(approve() transition)
...
Live (stat... |
Take the following algorithm with two separate sections, and the sections do not influence each other whatsoever (the function is not recursive, as well).
void algorithm(int x)
{
// This section of the algorithm has linear growth... O(x)
// This section of the algorithm has x * logarithmic growth... O(xlogx)
}
... |
A colleague of mine is against using DTOs and rather feels we should just return Entity / Domain objects serialized for a REST api. He feels DTO is an anti pattern and sited this article Data Transfer Object is a Shame. Although the article sited has a different approach to solving the "DTO Problem" as my colleague is ... |
I cannot go into the specific details of my project since it is in a very nascent research stage.
However, there is a fair bit of information that I can disclose. My project architecture consists of various Github projects that preprocess the data in a certain way. After a few parallel pipelines of different preproce... |
Let's say I have a Widget object that I serialize and send back to the browser at a regular interval. This Widget object includes lots of different members (variables) and other objects along with their members. For example, in PHP, my widget may look like this:
class Widget implements \JsonSerializable{
private $_va... |
I'm pondering a project in which one component needs to make a large number of http requests at accurate times. It should, let's say, release a set of 'dozens to hundreds' of requests at 1 second intervals. It is important that the requests are received by the other parties as close to the target time as possible.
Not... |
I am currently designing and developing a programming language from scratch. Mostly as a learning experience. Although it's not entirely related to the question, it's important that you know a little bit of the backstory.
I have a fairly good idea as to how I'll turn the code from my language into the target assembly c... |
Background
We have a ton of GPS devices in vehicles. These devices need to communicate with our system. To achieve this, we need to parse the device's messages before proceeding.
The following describes my scalable and fail resistant architecture idea.
Architecture
The devices are black boxes that send us buffers of da... |
Is naming a regular method init only confusing or is it an error?
class A:
def __init__(self, x):
self.x = x
def init(self, y):
self.y = y**2
def reset(self):
self.y = 0
I have encountered such a construction during review. Should I mark is as an issue?
|
I'm developing a Windows WPF app that needs to edit a certain type of document and I need a highly customized editor to do so:
The text is a transcription of an audio feed, and I need to sync the the text with a time code of the corresponding word in the audio stream (red numbers on left). This may involve breaking te... |
I'm looking for some advice about which line of code is more appropriate, readable, and maintainable.
1:
var result = mediator.Send(query).Result;
2:
var accountDetails = mediator.Send(accountFilter).Result;
The above code was taken from a Web API controller. The pros for each:
1:
If the query needs to change and re... |
I already have a solid back-end permissions authorization (ie. admin can perform an action, a normal user cannot perform an action).
However, I'm wondering if there is a better way to do a frontend authorization for my single page JavaScript application then fetching a permission from the API every view.
Seems like I c... |
I have a set of data:
id | name | parentid
------------------------
1 | parent | 0
2 | child | 1
3 | child | 1
4 | parent | 0
5 | child | 4
6 | subchild | 5
7 | child | 4
Which I can map to a hierarchy that looks like:
1 parent
2 |-- child
3 |-- child
4 parent
5 |-- c... |
Im going to be rewriting a library from .net to something that can be used on different platforms (Mac, Linux, Windows, Android). But i am also hoping that it can be used accross languages (c#, python, java). My initial thought was that c++ would be the best option. But ive never done something like this so im not sure... |
Along the lines of How v8 JIT compiler manages dynamically changing variables, wondering how you would go about creating dynamically generated variables in assembly. Not necessarily looking for example assembly code. More looking for a general high-level description of how you would define and then update a variable a ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.