instruction stringlengths 34 36.1k |
|---|
Suppose you're building a web application in ASP.NET MVC, and you have to display some formatted text. A very simple example might be:
Click any of the links below, or click here to cancel. Contact Customer Service with any questions.
What do you store in the resource file, and what do you code inline in your view?... |
Personally, I call this the Blueprint Pattern; however, I am sure someone else must have already named it. Static members, are in most cases, not a good thing. In languages such as C# and Java, they remove polymorphism and encourage poor class design. However, many times, there are properties that all instances share.
... |
This is sparked by this where an OP did not want to add a string he was using for a key lookup because he did not consider it property of the class.
To me the fact you are using it a for a lookup means it is a property. To me anything you search on would be a legitimate property of the class.
Could a lookup key no... |
I am a sole developer responding to a Request for Quote. The project is significant, and will take me more than 6 months to complete, (if I am the successful bidder).
One of the questions that I need to answer relates to 'knowledge transfer between employees', which is obviously difficult to answer for a sole develope... |
I am designing BC for Promo Codes. They work like this:
Admin can create promo code by specifying
Details (like Code and Description)
Benefit (interface for ValueObjects, for example MoneyDiscountBenefit)
Usage Restrictions - collection of AbstractUsageRestriction, each
restricting use of promocode, for example:
Pro... |
In my API library (C++) I am wrapping a shell process (spawned using popen) with several classes to manipulate a file system.
The base class ProcessFileWrap wraps general filesystem tasks and executes other custom tasks from its derived classes. It looks like below in pseudocode:
// ProcessFileWrap base class methods
... |
I am using c# but the question was more towards software engineering principals so I am asking the question here.
There are so many questions here but mostly they say :"How to use global variables in c#?" and "Are global variables are bad?". But my question is about "How" to avoid global variables in my scenario.
I've ... |
I have a resource that accepts transaction details as a subresource.
GET /resources/{resourceId}/ # get resource
POST /resources/{resourceId}/ # create resource
POST /resources/{resourceId}/resourceTransactions/ # post a resource transaction
Now when posting a transa... |
I work on a large software program in financial services. (15 project managers, 20 technical leads, 15 environments, 150 people on the technical side).
We do lots of Bankwide integration to hundreds of systems (insurance, bill payment, mutual funds, insurance, tax reporting, equities trading etc), which are frequently... |
If I understand correctly, REST was formalized by Roy Fielding as a descriptive model of the architecture of the web. AFAIK Fielding didn't claim REST was any good, he was just describing the de-facto architecture of the web. The web had already at this point proven an enormous successful distributed hypertext system, ... |
I have school project where me and my team have to build a health care system. It consists of different modules including :
A module for doctors : It allows a doctor to access the medical records of his patients, send indications to them, consult his agenda...
A module for patients : A patient can take an appointment w... |
I'm looking for architectural anti patterns / bad smells, and just wondering how to do this? Is there some sort of detection strategy, some way to find potential places or object-oriented metrics, suitable for finding these problems? This approach should be applicable on extracted / recovered architecture (from source ... |
I have a view controller with a mapview (Apple Map), on top of that there is a view with a button and a textfield.
The view is compacted around the search button, when I touch it it expands revealing the textfield.
I want to use the MVVM pattern so here are some questions:
Who should be responsible of the animation? T... |
I have a Session object, of which a single global instance session holds the current session, which can persist itself to the server, handle undos redos etc.
The session holds an instance of Objects which is in this example basically a set of Cars objects. When user changes e.g. a marker on a map representing a car's ... |
I believe it shows that I never worked on any major closed-source project so sorry for any misconceptions on my part.
Say a company is developing some software and needs to hire a contractor to help out. The contractor obviously has no right to take that software and start to compete with his employer as well as no rig... |
Current and common processing units are 8, 16, 32, 64, 128, etc bit. Why are their datapath multiple of 8 ? Is this all linked to the fact that the industry has settled with a 8-bit byte ?
The PDP-7 was 18-bit.
Pentium Pro address bus was 36-bit.
Many amd64 processors only implement 56-bit address space.
Is it a bad de... |
Background
I've designed and implemented a server app - a stateless REST API that mostly deals with customer CRUD operations.
As it is now the server is designed to use modules for each functionality instead of OOP concepts - although the 2 share some analogies AFAIK.
As an exercise, I'm trying to model some aspects in... |
My Rest API returns a tree structure like this:
[
{
"name":"test old",
"id": 1,
"type":"a-object",
"spend":13,
"status”: “active”,
"children":[
{
"name":"test women old",
"id": 2,
"type":"b-object",
"spend":13,
"status”: “active”,
... |
Why do many software developers violate the open/closed principle by modifying many things like renaming functions which will break the application after upgrading?
This question jumps to my head after the fast and the continuous versions in the React library.
Every short period I notice many changes in syntax, compone... |
I'm working on a project which has the following development strategy:
Frontend: Angularjs
Backend: NodeJs
DB: Mysql
I'm bulding a REST system with nodejs and I was wondering how should I handle the user session, exactly? Should I store the tokens in mysql?
Because I'm assuming this will be a delay in processing and ... |
I am fairly new to the microservice architecture. I am trying to build a web application in this kind of way. After some research online about microservices and having experience with Spring and Angular I want to build a web application with a separate front-end and multiple (separate) back-end REST API's.
How i want t... |
I am looking for an adjective; one that describes the opposite of "mutating". I want to use it to mark functions, methods and method parameters (including the receiver) as "not being mutated" by the function, similar how the D language does it.
Ds approach works pretty well for parameters:
class X {
void foo(const ... |
I am wanting to build a generic middleware software for my company that can access various vendors API's to pull out orders and then import then into our ERP through its API.
I want to make this as generic as possible whereby in theory, to connect another vendor, I just have to build out their implementation to conform... |
A little background of me - I'm a manual tester for almost 2 years within an Agile environment using SCRUM (1-2 weeks sprints). So I'm wanting to introduce automation testing in my work using Selenium WebDriver (with Java).
My question is during when should I test the functionality manually and when should I convert t... |
I am developing an application that will read excel files from disk and then process tests based on the data in the files. In order to keep the user interface from locking up when loading files and running tests, I have implemented the async/await with Task.Run() to handle the loads and tests running. Right now I onl... |
I have hard time wrapping my head around and finding a solution on how to design a working database structure for this situation:
We have a system that should collect data from Google Analytics & Search Console API - The connection works fine.
What I am stuck with is figuring out how I should structure the database to ... |
I'm developing a web application which stores sensitive information, which the user can access after a check that I built. This function then returns a download url to the user which leads to the FTP Server.
My concern is that it might be vulnerable to exploitation, people could alter certain url's to download files fr... |
Currently I have been working with speech recognition in java, and more or less have tried out sphinx where in I have been able to successfully get the word the person is trying to speak. So functionally I am trying to automate a software where in a person will speak, and my code will do the required action in java.
B... |
When a program is compiled, the code eventually ends up as instructions that can be executed by the processor. When for example a C program that writes data to a file is compiled, what code is in the executable file, is it just the code to call the OS write?
I have seen the comparable question that refers to use of Fra... |
I have the following database models and its properties:
User (id, role_id, name, email, password)
Role (id, name, description, active)
User2Role (user_id, role_id)
Customer (id, name, user_id)
A User has many roles.
A Customer is a User. But a User is not allways a Customer (e. g. Admin)
Now, how can i represent i... |
I recently found out that circular dependencies exist between some .Net assemblies from the following question and I'm looking for some explanation of why these exist:
https://stackoverflow.com/questions/43505621/circular-reference-in-net-assemblies
I've seen plenty of reasons to avoid circular references but are there... |
Following uses JavaScript code but F# is tagged for input from functional programmers.
I understand that in functional programming we shouldn't mutate the state or incoming parameters but I'm confused about formal request pattern when it comes to functional programming.
Formal Request pattern consists of an Object hav... |
For example:
scala> val a: String = "5"
a: String = 5
scala> val b: Int = 5
b: Int = 5
scala> a == b
res5: Boolean = false
I expect a TypeError, like in Java:
class MyClass {
public static void main(String[ ] args) {
int a = 5;
String b = "5";
System.out.println(a == b);
}
}
I wonder... |
When designing a framework API is it better to have something that accepts Promises or have executor functions and have the framework build the promises when needed.
The Promise API is defined by the syntax:
new Promise( /* executor */ function(resolve, reject) { ... } );
I have tried both and I am leaning towards ha... |
Quite simply, I was aghast when I discovered one of my unit tests was failing because -Integer.MIN_VALUE == Integer.MIN_VALUE!
Why would the language designers choose this, what is the mathematical advantage, and what are some alternatives I might consider in the future when dealing with edge cases?
|
Copied from stack overflow due to feedback
So I want to teach someone how to do dynamic memory allocation using the block padding model. What that means is every memory block is prefixed and postfixed with 4 bytes holding the length of the block in bytes along with a bit (held in the leftmost bit as that one should nev... |
Lately I've been interacting with a handful of SOAP APIs from different enterprise systems and I'm somewhat puzzled that oftentimes the WSDLs seem to indicate that they should be receiving XML data as a "string". For example a WSDL indicate the service expects data conforming to the following snippet of XSD for some op... |
I am a new lead developer that has recently started at a new company, I have been assigned to a project that is trying to consolidate functionality from lots of different applications already in widespread use in the business.
The problem is that their software development/project management are in the dark ages. I hav... |
I have multiple artifacts (applications) deployed on different hosts (let's call them A, B, and C for simplicity) and I am currently looking for some kind of integration pattern, because I need to reduce the number of calls to the backend, so that I don't need separate calls to A, B and C, but rather one call to D whic... |
I am developing C++ based multiplatform app. Core is in C++ and GUI layers are in native languages (Swift, Java, C# etc.). How should I handle localization for this? Should I use native solutions for platforms or create C++ based localization and pass strings via C binding API
const char * localized = CLocalize(const c... |
An empty array in PHP is considered falsey. That means the following will not print anything as the array is empty.
<?php
$myArray = array()
if ( $myArray ) {
print "My Array is NOT empty";
}
What is considered better practice in this case when determining if there are elements in the array:
To use if ( !empty( $... |
I have been working on Asp.net (Classic), where I need to render the lot of data in Telerik - grid.
During loading, its taking too much time. My doubt is which one is causing the impact.
Whether the compilation of server side to html controls.
DB calls which generate the data.
If compilation takes time means, then in ... |
Just like the two opposing mirrors are enough for infinity, most of design patterns can be applied repeatedly producing any amount of LOC desired. We can always create a factory for any factory or wrap a delegating layer around any class that already delegates.
This is of course somewhat artificial example, but I hope... |
Coming up to speed on the MVP design pattern and I have a gap in my
understanding. The consensus seems to be to design a 1:1 relationship between
Presenter and View. This makes sense -- but how would this work when state must be passed from one view to the next.
For example, imagine the following two View application;
... |
We have a few team members that have been working at software for a very long time and are not used to the idea of a version control system. These people are fairly good at what they do but can't get past organizing all of their work into files and folders. This wouldn't be so bad if there was at least some sort of nam... |
Given the official tutorial of angularJS,
https://docs.angularjs.org/tutorial/step_07#testing
It is apparent that it only tests the controller's states (e.g. its model) when events happen (e.g. http server response). However, this kind of tests cannot tests if the HTML correctly calls the appropriate methods of the co... |
I have a IItemProcessor class which takes each item from a list and send it to a web API (IApiService). The processing is done asynchronously, on another thread.
If web API responds with 'user not authorized', app needs to logout. For this, I have an IApp which has LogoutUser() method.
Currently, the ItemProcessor impl... |
Note: Still learning Haskell, not reached Monoids, studying Applicative Functors.
I saw this implementation and I am not entirely clear on it:
instance Applicative ((->) r) where
pure x = (\_ -> x)
f <*> g = \x -> f x (g x)
This is what I think:
Now I get what (->) r a is but I am not entirely clear on wha... |
Assume, I have a relatively large and complex application (100 MB .war file) with multiple dependencies. Some part of the code is defining an object factory, where similar objects (all inheriting from the same base class) are instantiated.
My goal is to convert these hard coded objects to plugins that can be loaded dyn... |
According to Martin Fowler's article,
https://martinfowler.com/bliki/TestPyramid.html
It is advisable to write more unit tests than integration tests. Does this mean ideally that every unit of work must be written with unit tests including all the edge cases? How about if there seems no point in unit testing, for inst... |
I have the issue that I want to be able to capture a set of SNMP messages, and some of them I want to parse to create an instance of a user-defined class. I may for example want to identify whether an SNMP message is a TRAP message, and if it is I want to identify the type of TRAP and create an instance of this type.
E... |
I'm using a repository pattern design and I've hit a stumbling block when writing a unit test for one of my methods. I'm fairly new to writing unit tests, so I would appreciate any help!
Let's say I have a method which creates a product and uses setters to set the data.
public function addProduct(array $data)
{
$ne... |
We have a Ftp server implemented. The manager wants to add reliability to it. He wants me to write incoming streams into some fast and reliable system (like hbase or redis) before writing them to server's hard disk. His point is if server has crashed (e.g power failure) before storing file, we have one copy of it in re... |
I am implementing the repository pattern in my application.
The repository will connect to an API to download orders from an external API.
The API that I am connecting to has a separate endpoint to get the list of Orders and a separate endpoint to get the Items against that order.
Where should the marriage of OrderItem... |
I have a small side-project of about 3,000 sloc. I'm experimenting with building a DDD-like domain model into it, so I have more experience with this style for work. The project is centered around reading and writing a specific file format which has not changed for 20+ years. And I'd like others reading my code to be a... |
Yesterday, the deployment of a financial website on a client was replaced with an older version which created unexpected issues and a downtime of almost 12 hours.
We came to know that two guys from their IT are creating problems for each other and it was done by one of them, don't want to go into the details.
This coul... |
I think that I know the answer, but I would like to be sure.
When jax-rs is used to implement a REST API, a @GET method should return an interface, implementation or an abstract implementation ?
If it returns an interface, sometimes it won't be obvious to know what it is really returning: for example, the json serializ... |
I was asked this question in interview, but could not find answer anywhere:
Lets say a application has feature which will unlock to different feature to diff customer lets say addition, deletion, edit allowed only for user1 user2 and user3, so I have already written code for all features and created exe, but when some ... |
I am currently writing a parser which, given a source file, turns it into an AST of some language, respecting the idiomatic process of lexing and then parsing using well-known parser generators (think lex and yacc). However, I am unsure as how to properly distinguish which steps should happen during lexing and which du... |
I’m coding a Hash-Life implementation in C++14 and working on a multi-threaded implementation. It has obvious potential for multi-threading. The task can be broken down into essentially 13 sub-tasks. 9 of the tasks are largely independent and the other 4 depend on 4 of the 9 but not each other. One one makes 9 (paralle... |
I'm developing an enterprise web application, hosted on site and managed by the corporate IT team. I do not have remote access to the server, and the only way in is through the web interface. I'd like to install the phpMyAdmin-like Adminer (https://www.adminer.org/) so I can do database maintenance remotely.
How do I ... |
As someone who hasn't really gotten into large-scale corporate software development--I'm 17, I wanted to ask a question about programming practice.
If you encounter a bug in an application, and you apply attempts at fixes, before realising the actual fix to the bug; should you revert your original fixes, if the applica... |
I have been tasked with writing unit tests for an existing application. After finishing my first file, I have 717 lines of test code for 419 lines of original code.
Is this ratio going to become unmanageable as we increase our code coverage?
My understanding of unit testing was to test each method in the class to ensu... |
My team doesn't write tests for generated code (e.g. some POJOs). An engineer that I greatly respect recently wrote this on the subject:
Research over the past 10 years has revealed that generated code is as
prone to bugs as other code, and in many cases the bugs in generated
code are far more costly to triage. He... |
In our code base, I see a lot of code like this
var error = ValidatePhoneNumber(userId, phoneNumber);
//if validation fails, return error
if(!string.IsNullOrEmpty(error))
{
return error;
}
If I were writing this, I would have just had ValidatePhoneNumber(userId, phoneNumber) throw the error and call the method in... |
I'm trying to wrap my head around OOP when building simple CRUD systems, using the Repository Pattern to handle object retrieval/saving to persistent storage.
I've already designed and implemented a system that doesn't use OOP, just straight up get, insert, update and delete functions that contain SQL queries.
Non-OOP... |
Let me introduce you into a minimalistic and made-up case with real-case chronological order, updates and problems.
User with ID only
I had a system, and it had User entity with ID column only. So, there was a class User and SQL table Users:
[Table("Users")] // database table
public class User
{
[Key]
[Column("... |
I plan to write a library in Java, consisting of packages A, B, C and so on. Every package encapsulates a part of the big picture. B relies on A, C on B and so on. For this purpose every package offers a single class to the next package. However, every package is optional in that the user can decide to substitute their... |
I have been adapting poor-man's CQRS1 for quite some time now because I love its flexibility to have granular data in one data store, providing great possibilities for analysis and thus increasing business value and when needed another for reads containing denormalized data for increased performance.
But unfortunately ... |
I've got a set of immutable POCO objects that reflect database content. These have a one-many relationship:
Property has one PropertyType, which has many PropertyTypeMetadatas.
Because Property has only one PropertyType, and it holds information that is frequently going to be used by the consumers of Property, I've add... |
I am building a repository that will request data from an API.
Originally, I had multiple methods in my repository such as GetOrders(), GetOrderItems() etc.
The majority of these functions had almost the same method body except they:
Had a different end point URL
Deserialized the JSON into different objects
Have a dif... |
I got one project which contains JavaScript code. No unit tests were written for JavaScript code.
So it is feasible or beneficial to write unit test cases using Jasmine Framework for code?
What are benefits or challenges may I face while doing this?
|
I've encounter yet again this situation where programmers are using autogenerated models (from LinqToSql, EF, nHibernate, whatever) as view models.
Usually the architecture is very simple :
Some kind of DAL containing only EF or LinqToSql
Some modules for very specific stuff
MVC project
It may or may not contain a ... |
I would expect any build that I ever pulled from a repository to just compile, along with any dependencies that are required. Likewise, I would never commit anything that didn't at least compile. That is to say that there could still be known bugs or errors in the build, but at least it compiles. But this is how I do t... |
Looking into incorporating ideas of Domain Driven Design into an application however our data model is not really a good fit for ORM like Hibernate. Very old database / data model, lots of compound / natural keys, lack of foreign keys, etc.
The item I am struggling with is how to design the domain layer without ORM si... |
I'm fiddling around with OOP in building simple CRUD systems.
I've decided to focus on using the Repository Pattern for separating Object business logic and Object data persistence (actually saving the object in a persistent data store, i.e a database).
Saving a simple object is straightforward
class Customer {
setD... |
I have multiple ASP.NET Core web applications that need to share an employee database. I want to be able to write the Repository and Models once and use it in multiple projects.
What is best practice for this and how can I achieve this with ASP.NET Core?
Using VS2017, SQL Server and IIS right now.
|
Let's say we have the classic Invoice object.
This Invoice object has various properties, including a Product and Customer object.
The Product object has a minimum of 15 properties.
Now say i have a list of invoices of customers who all bought the same product. When I serialize this data to the client, the size of th... |
For some rest resource, there are two fields connected. There is, if one field is POST/PUT it gets the value of the other field.
In this example we have a amount and amountWithVat(with tax or Value Added Tax).
If you POST or PUT a null for amountWithVat the default value will be from amount.
Example 1
POST
amount=150
... |
So I am reading Clean Code. In the Meaningful Names chapter, they lay down a rule of no verbs in class names. However in the Adding Meaningful Context section of that chapter, on page 29, he uses a class name GuessStatisticsMessage.
How can we validate the use of Guess in a class name, even though it is a verb?
|
So I am reading Clean Code and I want to write my class names with the proper amount of context, but how does .NET namespaces play into the concept of Meaningful Names?
Do I forego context in the class name that has been provided in the namespace?
For example, If I have the following namespaces
MySolution.Event.Regis... |
I've written some python code that is using a module which is distributed under an MIT license. Three questions.
Do I have to release my code as open source?
Can I distribute my code commercially?
If I cannot do any of the steps above, is there a license that will allow me to do that?
|
I have some code in process A that needs to wait until work completes in other processes that can be running simultaneously under multiple users.
I'm uncertain what is the appropriate synchronization mechanism. I naively thought a global named semaphore would be the answer but semaphores are signaled once anyone relea... |
I'm creating an interface to record navigation history.
First thing is, we have three types of records: Recordable (the default behaviour), Revisitable (a user can look at their history and revisit that item), and Traversible (the user can simply "go back"). Traversible records are, by definition, Revisitable which are... |
I'm working on a project with an AngularJS app that talks to a RESTful API. We've just started writing E2E tests for the app in Protractor. I'm fairly comfortable with unit testing but new to end-to-end testing.
We're writing a test that tries to send a message. Currently the test fills out the form, clicks the send bu... |
I recently got into a debate with another developer regarding the below class:
public class GroupBillingPayment
{
public void Save(IGroupBillingPayment model)
{
if (model == null || UserInfo.UserID == 0)
{
throw new Exception("GroupBillingPayment object or Current User Id is NULL , P... |
I am starting a new project, which will take two existing projects, use part of the functionality of each, and will add new functionality.
As usual, both projects don't use standard C types, preferring to typedef their own.
All code is in C, not C++, so obviously, both projects wanted a boolean type, and both have typ... |
I want to design a system where people use a house.
People in a house can walk around, sit in chairs, eat food, watch TV, cook, clean up, poo etc.
So I wanted to start off with the smallest room in the house. The toilets.
This is what I did.
So this doesn't look this bad right now, but I'm scared about adding another... |
I have a web application the mobile app users are connected it by using websocket.
The server has data A that can be changed in time. And the clients (mobile app) have data B that also can be changed in time.
When user emitting a message (a request to get data D) to the server by using websocket, I have to apply loops ... |
I am working on a themable website, meaning the administrator can pick primary/secondary colors to customize the UI.
The website is build in .net and the style rules are written in less.js. The current implementation uses a homemade webpack plugin that bundles the less files together. Some less files contains undefined... |
Why would someone develop his own language to use it only inside that firm when you have XY other languages that can help you with their libraries, logic etc.? Isn't it way much simpler to go with the flow with anything else rather than developing your own language?
|
I am going to build a simple asp.net web api application which will send request to 3rd party service and then return back the response to client.
Before sending request to external service,
I need to prepare request payload from DB and also need to validate it.
After validation I will send this payload to 3rd party s... |
If I look in python code and sometimes maybe also in C codes, there is often two variables with the same name except for the underscore. For example two variables
variable1 data;
variable2 _data;
Why is it like that and what is the background?
|
When I look at at some PHP applications, they typically have hooks. Drupal and Wordpress are examples. When I look at an application from the .NET world like Orchard or Umbraco, one subscribes to events.
On the other hand, I saw Drupal also has events, https://www.drupal.org/docs/8/modules/simple-fb-connect/eventsubs... |
Per MVC design pattern as in GOF, "a view can be disabled so that it doesn't accept input simply by giving it a controller that ignores input events". That means, we decide a view first and then pick a suitable controller to that as the scenario needed.
But iOS storyboard based development is primarily driven by Contr... |
There is a quite a bit of information about the time complexity of inserting words into a Trie data structure, but not a whole lot about the space complexity.
I believe the space complexity is O(n**m), where:
n: possible character count
m: average word length
For example, if the available characters are a and b, then n... |
Assume the following:
/// file.ts
var x = "hello";
x = 1;
console.log(x);
/// file.ts
function transpile(fileName) {
...
}
What steps would typescript take to transpile the file?
How and when the typescript safety check cause the second line to become an invalid assignment? (Edit: in Visual Studio designer this ... |
Are we supposed to write code differently to handle running through a system proxy for Http requests?
I have developed an application which uploads many files from a clients network over the internet via a REST API over a long period of time. I run it on a PC in their domain.
However, when I run it on one particular c... |
I am trying to understand the goals of Java EE specification.
I suppose Sun could just build a software package offering all those functionalities? Kind of like Spring.
Instead they thought it was better to build a specification and allow other vendors to implement it.
Why did they think so and what exactly is achieved... |
I am investigating ways of making my bundle of python network-requesting processes more efficient and became interested in the likes of Go and Julia for their apparent strong concurrency support and green threading model.
As I read into user level threads it sounded like what I was actually interested in was kernel lev... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.