instruction stringlengths 34 36.1k |
|---|
Everyone seems talking easy about it but I don't get it.
.NET Standards is a subset of functionalities of every .NET frameworks that you have to follow if you want to make your framework .NET Standard compliant and so compatible on all the platforms .NET can target.
Then why I have to specify manually "netstandard20", ... |
We recently upgrade to PMD 6.0.0 and are getting several classes flagged as "Data Classes"? It argues that it breaks encapsulation and makes for brittle design (I understand that this site has a different opinion).
Let's say that our team decides to go ahead and refactor the data class, instead of ignoring the PMD rule... |
This has been on my mind as I developed several applications with this feature.
Suppose that an application is required to process incoming requests in an asynchronous manner. Take the example of a notification system (other agents will submit a request for the notification to notify people via email or text, etc.) In ... |
According to the Single Responsibility Pattern (SRP) a method or class should have one responsibility. I have read a couple of sources and viewed some videos and I would like to understand it by writing some code samples.
According to me, the following:
def addAndSubtract(a,b,c)
a + b - c
end
is conflicting with the... |
I'm thinking of making a realtime chat app that would allow me to store user messages into a MySQL database. So far these are the two ideas I have.
1) Create and API which the message is sent to and then saved in the database. After the message is saved into the database a push notification is sent to the person who is... |
What I am going to discuss is typical situation.
Most of the developers I know work on functionality first and then on design.
BUT, when clients check the builds, they usually check design first without bothering much about functionality.
And since we are creating for clients, shouldn't work on what clients are going t... |
I am designing for a new application and I don't want to suffer later for the performance that manges discussion threads (posts + replies, very similar to Facebook or StackOverflow posts).
I wonder which kind of data store / data format I shall choose to persist the threads. I looked for an answer to my question, but... |
I have a Python project where I have a few classes that model various thing I'm considering (e.g., a car class, a driver class and a street class) and then I have a single helper function that does a simple, low-level operation, that I use in some classes.
Is it considered good practice to put this function in a separ... |
There's a large shared object (kind of OpenGL context) in my project.
It is accessed from multiple threads.
To ensure only one thread at the moments is using SHARED_OBJECT, mutex (kind of NSRecursiveLock) is used.
The problem is that sometimes MAIN_THREAD is waiting a lot while some BG_THREAD is doing something with S... |
I have a class library that calls dll_A.
dll_A has dependencies on WPF.
How to I wrap or isolate my class library so that the code calling my library does not need to have a dependency on WPF?
(My class library obviously has to depend on WPF, but the only output is Byte[]).
In other words, I want my library to act as... |
I have to compute small mathematical problems for my work. My main work is to develop and solve these problems analytically. I then have to compute these problems in mathematica, but this is not my main task.
I am not unwilling to do this, but I think I could save time by outsourcing it to someone with more technical e... |
I have a couple of inactive Pinax sites at different versions (0.9.x and 0.7.x). These both started with two common features:
While the version of Pinax was the most recent to have a (nonempty) social starter project, they were both relatively old; and:
Installation hinged on procuring some extremely rare and difficul... |
I’m seeking a term and possibly the code behind what would help me implement that term in Python.
I have been working on a text-based Python journaling application.
When I want to review my journal from the command-line shell, it prints out a series of logs like this:
Log_1”...”
Log_2”...”
Log_3”...”
The problem... |
I'm a first timer here so let me know if I should post this question in a different forum!
I have a python program that takes in user input but is only useful when you're offline, I wanted to make the ui better so I thought using HTML CSS, and JavaScript would be perfect. So my question is, is it possible for python an... |
I am new to AWS and i have learnt and developed code in spark -scala .
My application basically merge two files in spark and created final output.
I read both files (MAIN files and INCR files )in spark from S3 bucket .
All are working fine and i am getting correct output also .
But i dont know how to automate whole pro... |
My question is in context with the Serverless Architecture (e.g. AWS Lambda) and how does one interact with the Databases in this system.
Typically in a 3 Tier architecture, we have a web service which interacts with the Database. The idea here is to ensure that one database table is owned by one component. So changes ... |
I have written a basic web app in PHP, using MongoDB as database engine. The app basically inserts records into database as they become available, and queries the database and displays the data as on a web page when the user visits the page.
When the database is queried and cursor is returned, some processing is done o... |
I read about payara(glassfish) server cluster and find out that clustering with payara only replicate session in multiple servers.
but I use jwt for my project so I don't use session at all.
I decided not to cluster servers and just use multiple servers without connecting to each other and have Load Balancer in-front o... |
I'm not even sure "relevancy" is the most accurate word, so I'll just describe the problem:
I'm building an app that needs to somehow parse product descriptions from a popular website (let's just say it's Amazon) and figure out which certifications the product has based on the text in the description alone. The descrip... |
I have read couple of articles on google but not sure how DB client for example java application connect to clustered DB.
All the articles I read says client will write at master node but will use slave for read.
My question is how client will know which one is master(and its location) and which one is slave(and its lo... |
There exist a number of articles/blogs explaining the Dependency Inversion Principle (DIP) using Swift; to name a few (top Google hits):
GitHub/ochococo/OOD-Principles-In-Swift - The Dependency Inversion Principle,
clean-swift.com / Dependency Inversion – A Little Swifty Architecture
Now, Swift is widely described (e... |
I really love the way open source projects use RFC as a tool to get feedback and ideas from the wider community. I've been especially noticing this over the years with the way Ember have been doing their development.
I'm thinking about RFCs in the context of 'closed source' projects. The kind a consultancy or a softwar... |
I have the following pure function (f2 and f3 are pure too):
class X {
def f1(arg: Type1): Type2 = {
val x = f2(arg)
val y = f3(x)
y
}
def f2...
def f3...
}
Now, I would like to move f2 and f3 and can think of 2 options to do so. Wondering if one is more functional than the other?
Option 1
Move... |
I am struggling to define methods in OOP. Currently I am practicing with this scenario: "A hospital has started the development of a new system to keep records of analysis done by patients and the doctor who asked them."
I defined four classes: Patient, Doctor, Analysis and Hospital.
Patient: represents the person who... |
I have an iOS app that currently has over 2500 images. These are generated into an asset catalog to make use of thinning (2500 x 5 variants = lots of files). The files are largely accessed at random.
Batches of files will be downloaded via in-app purchase. Eventually, I'll end up with 10K images, so possibly 50K files... |
Here is a piece of cool code to add the two integers, a and b:
NameService nameService = NameService.getSingletonInstance();
OperationService operationService = nameService.resolve(OperationService.class);
ValueFactory factory = OperationServiceFactory.newInstance();
AbstractValue va = factory.newIntegerValue(a);
Abstr... |
We have a very large search service (written in golang if it matters) that runs on top of ElasticSearch, receive requests, builds the correspondent query, and returns the results (with some post-processing). The service handles thousands of requests per second and should be able to serve requests quickly and efficientl... |
If I have an app that will authenticate users using ActiveDirectoy and will Authorize them and link data with them that are stored in Sql DB.
Which one is best practice ?
To import data repeatedly from AD and store in DB as (Id, UserName) and each time I'll authenticate I connect to AD and make sure its password is ... |
I work on a java web-application.
In this application, users can generate some reporting (xls/pdf) and create some pack of multiple reporting. (using pdfbox, itext)
More and more data are added in the application since few year.
The generation of reporting is made on the same server as the application, which doing slow... |
First off, I am aware that many questions have been asked about VCS as a solo developer, but they are often too broad. This concerns only branching, and still it has been marked as a duplicate...the supposed duplicate is, again, marked as another duplicate of another question that is too broad and doesn't concern branc... |
Note - This is about software engineering.
A friend at work said:
Did you know that Facebook and Atlassian have abolished project managers for their software dev teams?
This sounded familiar, but I couldn't find a reference confirming this.
I'm asking the question how is it possible for large companies to have soft... |
I create copy of this post here because this place more relevant for my question and I don't remove original question from stakOverFlow because I got comments and start conversations with users.
I often meet in my code or in code from colleagues with bunch of init methods in onCreate() method in Activity and it's looks... |
We would like to use Driessen's git branch model but we also have QA side. I think I understand how this git flow works but I'm still not sure about testing. For example, I have five new features, each of them is in my own branch and I want to give these features to testing. Now I'm confused about where to merge them? ... |
I have observed in lot many C# example where in following pattern is being followed but i am not sure how this will going to help us in long run
Typical approach i have seen is
create a interface
implement interface
create a manager
call manager
it would be really nice if anyone can tell me how this approach wil... |
I've been using Linq for a while unknowingly that it uses a Reactive pattern that I'm quite fond of.
I'd like to roll my own function in that pattern but wasn't sure if it's appropriate and also wanted to throw out ideas about how I would do it.
My goal is to make a video player service that is injecte dinto classes, t... |
TLDR; I have one repo interface and multiple data sources, each with a different data identifier - how can I maintain having only one method in my interface?
I have a need to read a domain object OrderData from two different repositories: one is an outside service and the other one is a local database.
Let's call them... |
It is generally agreed that overloading a method should not change its behavior, but how much of a method's behavior should be kept consistent?
Take for example a REST API client which is responsible for interacting with two different endpoints. Both consume a POST request, share the same base URL, and accept the same ... |
Our company runs applications on a Micro Service architecture that includes thousands of services. I am working on a backend application "X" that talks to 50+ services. Frontend services call my service "X" to execute requests on other services.
Problem:
Front end wants to show user friendly messages when something f... |
Edit added 2+ years later
I "checked" the @dandavis answer because it answers my original question, giving reasons to prefer const foo. However, I am completely convinced by the @Wayne Bloss answer that function foo() is generally superior.
Original Question here
For example, in this Redux video, the instructor always... |
See the comment inside ChildEntity ::__construct():
class ChildEntity extends ParentEntity
{
/** @var int */
protected $classParameter;
function __construct(int $classParameter)
{
/**
* Question
*
* Below are the two ways of initializing the variable of ChildEntity
... |
In the past year, I created a new system using Dependency Injection and an IOC container. This taught me a lot about DI!
However, even after learning the concepts and proper patterns, I consider it a challenge to decouple code and introduce an IOC container into a legacy application. The application is large enough t... |
I'm using an internal library that was designed to mimic a proposed C++ library, and sometime in the past few years I see its interface changed from using std::string to string_view.
So I dutifully change my code, to conform to the new interface. Unfortunately, what I have to pass in is a std::string parameter, and so... |
I'm currently trying to map how to make a good algorithm that won't have issues to find the shortest path. The labyrinth consists of an X and Y dimensions as input; However, the labyrinth will generate obstacles within the dimensions and randomly spawned. There is one entrance and at least one exit after finding the sh... |
I am trying to test a function that creates a message exchange graph from IRC chat logs. I am having trouble trying to mock the dependencies. The function makes use of util module. The functions inside utils receive arguments and return an output after some processing. The problem is that these utils functions are bein... |
I have seen most of times developer declares the string in below fashion
Approach 1:-
public void method1(){
String str1 ="Test";
}
Approach 2:-
Per my understanding better approach will be
public void method2(){
String str2 = new String("Test");
}
Again based on my understanding , Second approach is better than fi... |
I am developing a mobile app in android in which I use Telugu (Indian language) texts. On my mobile Telugu language alphabets are available. Therefore, I am not facing any problem for testing my app. These characters are available in android studio also. So if I give the Unicode codes ranging from u0C00 to u0C7F in es... |
Is the following class definition a good design?
class Myclass:
def __init__(self,num1,num2):
self.complicated_tree = __class__.object_creator(num1,num2)
@classmethod
def tree_creator(cls,num1,num2):
return num1+num2 #in practice, this functions would be really long
... |
My team and I are trying to set up some integration tests of a distributed system that is highly dependant on the flow of time and events coming from external sources. Just to give you an idea about what we're working on:
when event A is received within 8:00 AM and 9:00 AM, and afterward,
within 5 minutes, a second ... |
In my board game I want to decouple my Player and Board class since I've changed piece moving system several times now and it's been a chore each time. I think I could use some interface for taking a player request to alter the board state but I can't decide if a Command or a Mediator interface is the appropriate solut... |
Here's a scenario I've encountered variations of on many occasions.
Imagine an XML feed which displays data about three different types of event: concerts, plays and movies. Each has a different set of parameters. We want to scrape this information and store it for our own purposes. So we create a database which has ap... |
The default behavior of assert in C++ is to do nothing in release builds.
I presume this is done for performance reasons and maybe to prevent users from seeing nasty error messages.
However, I'd argue that those situations where an assert would have fired but was disabled are even more troublesome because the applicati... |
I was talking with some coworkers about the application build and we have some divergences about what each one consider a good practice or something to worry about.
I learn that a good application build is one that is self sufficient, no matter how many dependencies and tests it have, the build will take care about the... |
I couldn't find a specific answer to my question but how would I develop an AggregateRoot class for the following scenario.
public class Root{
public int Id {get;set;}
public IList<Child> Children {get;set;}
}
public class Child{
public int Id{get;set; }
public IList<SubChild> SubChildren{get;set; }... |
I am a member of a 6 person team of software engineers within a 400 person department at a fairly well known company. We are responsible for the business applications our department uses, both third-party and custom asp.net tools we write. The group has been around since 2006ish and I joined in 2011. I have been try... |
I understand an event-driven architecture leads to decoupling. However, can using an event-driven architecture lead to minimal "getter/accessor" use? It seems that if you had some type of event handler such as BalanceChanged that passes the new Balance around then you wouldn't need a getter to access the Balance of a... |
I have three attributes for a user: connectionId (e.g. "sd4-h4sdg-u4j-a2rr3"), userName, and placeInLine.
I can't think of a single data structure that will handle my scenario of only allowing a single user to work on a given webpage resource and advancing the line of people as each active user leaves their connection.... |
I'm trying to implement this right-to-left evaluation algorithm of a postfix expression but I can't seem to get it to work.
for each token in the reversed postfix expression:
if token is an operator:
push token onto the operator stack
pending_operand ← False
else if token is an operand:
operand ← token
... |
My program (a command-line utility) will load configuration from a file, using defaults if file not found, and I'd like to do this in a cross-platform manner that people will expect.
Is there a de-facto standard or other common algorithm for searching directories to find the config file?
I'm imagining something like:
... |
I am a bit confused as for what it really means. In the related questions (Is this a violation of the Liskov Substitution Principle?), it was said that the example clearly violates LSP.
But I wonder, if there is no new exception thrown, would it still be violation? Isn't it simply polymorphism then?
I.e:
public class T... |
I believe there is a person who named this pattern or practice and would like to know the correct nomenclature to avoid confusion.
object.propertyA.propertyB
becomes
object.propertyB
|
We are discussing proposal to split a big C++ program into multiple separate executables that would communicated using shared memory. The shared data structures are large, so we do not want to use loopback network or any other approach that would just copy them.
The arguments for splitting are that every part can be de... |
We have recently moved to Java 8. Now, I see applications flooded with Optional objects.
Before Java 8 (Style 1)
Employee employee = employeeServive.getEmployee();
if(employee!=null){
System.out.println(employee.getId());
}
After Java 8 (Style 2)
Optional<Employee> employeeOptional = Optional.ofNullable(employeeS... |
I was just wondering this while programming in python. If I have a function foo which take a collection (list or tuple, perhaps set etc.) and manipulates on its elements somehow, e.g. filter, trim, increases, etc. should such function return the same type? For instance, if it accepts any collection and filter things ou... |
About the app: This is an android app. The app has two components/ two different users, scorers who score the game and fans who view commentary of the game.
Scoring User : A scorer watches a live baseball game and puts the
score after each pitch/event of the game. These events are pushed to the server and also stored... |
As our devs are writing internal applications, often times we need to share code. There are various ways to do this, but it usually comes down to creating a nuget package on a shared server or hosting a web api internally. We don't have a definitive way to decide between the 2 and currently have a mixture of both. Any ... |
On my current project it is a common practice to generate Hibernate Entities from database tables using NetBeans functionality. I'm normally used to first write the Entity-class and define the mapping in an XML-file or with annotations.
Is it considered bad practice to generate the entity classes through NetBeans (or a... |
I have a question around which is preferred and seen as more right approach.
Out company's messaging solution of choice is Kafka. We have a task to build a service that would provide events in cloud environment via HTTP(no port opening, widely used - easy to get clients onboarded). Events originate from company's own d... |
I've read several papers, articles, and section 4.1.4, chapter 4 of Compilers: Principles, Techniques, and Tools (2nd Edition) (a.k.a "The Dragon Book") which all discuss the topic of syntactical compiler error recovery. However, after experimenting with several modern compilers, I've seen that they also recover from s... |
For my personal project I need to store 2D shapes in a Postgres database. For example Circle, Pentagon, Rectangle and so on. At first I've done it like so: all shapes are inherited from an abstract class called Shapes, which has some methods that I need each object to perform on itself, for example (I'm using java wit... |
Is it OK to have a class something like this
public class Weapon {
private string name;
private int might;
// etc...
private Weapon(String name, int might) {
this.name = name;
this.might = might;
}
public static final Weapon Alondite = new Weapon("Alondite", 16);
// 100++ w... |
I'm trying to figure out what my API route and HTTP method should be for supporting a dual list box (e.g. http://geodan.github.io/duallistbox/sample-100.html)
Say, I have a collection, GET /employees which looks like:
[
{'id': 1, 'name': 'Foo', 'selected': true},
{'id': 2, 'name': 'Bar', 'selected': false}
]
where... |
I suppose I have the following use case:
I want a synchronous service if possible (in case of machine crash I want to finish it in background, by some other node)
I want to save something in my database and publish an event to an event stream like kafka or kinesis (which means 2 transactions db + evt stream)
I am sta... |
There are endless resources on creating CRUD for REST resources but I can't find much on doing the same for Messaging.
Given two services A and B where A receives incoming requests that initiates the creation of the resource R. When A receives the request it does some processing and creates R and then wants to store R ... |
Occasionally I see major, relatively new, open source C projects targeting very old C standards, typically C89. An example is systemd. These projects have intelligent people at the helm so they probably have a good rationale behind this decision that I don't know about. That benefit of the doubt aside, it almost seems ... |
I have the following entities in my database (it's simplified):
Student (id)
StudentCourse (id, student_id, course_id)
Course (id)
Lesson (id)
LessonCourse (id, lesson_id, course_id)
StudentCourseLesson (id, student_id, course_id, lesson_id, completed)
So:
Student can sign up for a course (StudentCourse entity is be... |
I have requirement like user can booked space (office, room, meeting room etc) for a rent for particular time period. But requirement is like user required to booked space every month 5th date, or they need that meeting room in every week Friday.
I have no idea from where to start for store data.
How to design class or... |
When I'm writing an computer-vision program (using OpenCV and Python) I need to print/show a lot of intermediate results in form of images (using cv2.imshow(..)) for debugging purposes to find out what is happening. After finishing the program I have no idea what to do with this "debugging code". Because this code is u... |
I am trying to encourage working practices that are more agile. I am trying to understand the difference between a Use Case and a User Story. I have read a lot of articles and questions like What's the difference between "use case", "User Story" and "Usage Scenario"? and Is it reasonable to assume a 1:1 relationship b... |
I'm building an Mvc application with microservices that retrieve information from the database.
I have a question related the microservices.
I want an entity from database with some property in a page of the application. So I've build the method of the service that retrieve the information.
In another page, i want the ... |
To use Strategy Pattern in Objective-C, I think it is mainly by selector.
To omit if...else, use Objective-C runtime, convert string matching to choose selector (Strategy).
Am my understanding right?
Here is demo: Strategy Pattern in ResponderChain Communication Pattern.
create a Router to use ResponderChain Communic... |
I am trying to create a web UI for image processing, with some operations similar to what a site like fotor.com offers. However, I have problems to achieve a similar performance. For example, lets say I uploaded an image on fotor.com of around 3+ MB and performed a basic operation of setting the image brightness to "fu... |
I am a freelance developer. I have multiple clients, each client has multiple projects, and each project has multiple distinct pieces of software. I recently migrated all my source control from my old subversion service to a business github account.
My question is, what is a workable strategy for organizing clients, p... |
Can anyone point me to patterns for, or material on decentralised federated system design / federated data/service architectures?
To give some more background on the problem I'm looking to solve, here's the full context. I've had an idea floating around for a while to create a "reverse address book". i.e. Rather th... |
When to use else in conditions?
1)
a)
long int multiplyNumbers(int n)
{
if (n >= 1) {
return n*multiplyNumbers(n-1);
} else {
return 1;
}
}
or
b)
long int multiplyNumbers(int n)
{
if (n >= 1) {
return n*multiplyNumbers(n-1);
}
return 1;
}
2)
a)
int max(int num1, int n... |
E_d is an environment where one can develop, build and test a .NET web application.
E_p is the production environment, where only running the application is possible. That is, build is not possible.
Repo_src is the source code repository.
Now I would like to implement a poor man's application update mechanism (for bina... |
My office uses Git and SourceTree for our version control. This came about because when I joined there was zero version control and SourceTree was the only system I had ever used. I am not an expert by any means, but I am the most experienced out of my coworkers so I am the de facto expert responsible for teaching ever... |
I'm creating a game (well, a plugin) where each player has a list of skills, each of which has an unique type object, each of which has a list of actions that need to be ran when a player executes his skills. I drew a diagram to show my classes: https://i.stack.imgur.com/NOdDF.jpg
And here's a quick mockup in pseudo-py... |
I'm asking this question coming from a background of no experience in web development, so please be patient as I attempt to explain what I'm doing (if I use the wrong terminologies or if this has already been asked. Tried searching, but I don't exactly know how to concisely ask this question).
I have a server I've dev... |
I have built simple auth for REST servers in academic projects. I always used the headers to pass the credentials. This is probably just because every tutorial I've ever seen did it this way. Initially, I'd have header fields for user and password, but I eventually switched to basic auth. Anyway, whatever it was, I alw... |
Imagine I have an abstract class Node which has several methods and attributes. (Join a network, send a message, broadcast ...).
I want to be able to add/remove functionality to/from that Node class (Routing functionality, mining functionality, ...)
I was thinking about using a Decorator pattern since that let's me cha... |
I am learning a lot about this principle (also thanks to two answers I received here) and would like to elaborate on another point that somebody mentioned.
1) Is the following a violation of LSP?
class Base
{
public virtual void UpdateUI()
{
//documented: immediately redraws UI completely
}
}
class Co... |
I'm trying to understand DDD and one of the key concepts in DDD are the Domain Objects. As i understand they're supposed to 'hide' the internal state and allow modification of it by only by using methods (behaviors?) and only in a way that keeps the (internal) state always valid.
Would it be an over simplification to ... |
I want to calculate the runtime of the following function
T(n) = (1+2+3+4+5+...+n)/n
At first this doesnt seemed hard to me because it can be solved easily by transforming the formula
T(n) = (n(n-1)/2)/n = (n^2-n)/n = n-1 which leads into O(n).
By thinking about this function i struggled. I am not sure if I am allowed ... |
I looked trough some of my older code and found that I was using the using namespace directive. From what I read in a lot of google results, it seems that it is never a good idea to use this. Is there actually a valid use case for this construct or was this just a misguided attempt to make peoples lifes easier, that fa... |
Suppose I'd like to implement the templating pattern, but the only real differences between the subclasses are their choices of some invariant dependencies.
Is there a drawback to preferring this style:
public abstract class AbstractClass {
private final DependencyA dependencyA;
private final DependencyB depend... |
This project will serve many duplicate requests with location-specific answers. I.e. 10,000 people in New York will all get the same server response (a list of businesses in New York), but one person in Atlanta will get completely different data (businesses in Atlanta).
Planned architecture:
1. In memory cache which... |
In the comments to an answer of another question, I proposed the following Java code as a better way of writing a more procedural-style variant of the same operation:
employeeService.getEmployee()
.map(Employee::getId)
.ifPresent(System.out::println);
(where getEmployee() returns an Optional<Employee>)
An... |
I'm writing an app which tracks device location and based on some factors (user gets an assignment), it needs to change the location tracking settings (for example, frequency).
I have an issue with how to design this.
// I left out methods to start\stop tracking
interface ILocationTracker
{
event EventHandler Locat... |
I am learning Python and when I learned that we can build Custom classes for exception, I got into a confusion of Why ?
for example1 :
class MyException(Exception):
def __init__(self, error):
self.error = error
def __str__(self):
# DO THE WORK TO BE DONE FOR THE EXCEPTION
prin... |
Let's say we wanted a typeful, pure functional programming language, like Haskell or Idris, that is aimed at systems programming without garbage collection and has no runtime (or at least not more than the C and Rust "runtimes"). Something that can run, more or less, on bare metal.
What are some of the options for stat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.