Menu
  • HOME
  • TAGS

Is call_user_func_array the way a page is served in PHP frameworks?

php,model-view-controller,design,frameworks

The call_user_func_array() function is used for when you don't know the function you are calling ahead of time. This is why most of the time, the parameters inside are variables. If you know what function you want to call, always call it manually, otherwise, use this php in-built function. You...

Django object composition with OneToOneField

python,django,design,orm

You are right, the related names must differ. Simply check for the existence of the given subtype: Widget.objects.select_related('workwidget').filter(workwidget__isnull=False) ...

Employee and Customer = People Table?

mysql,database,design

My personal preference: separate out customer and employee database. While some of the data may be same between customer and employee, it won't be long before data requirements and rules start differing. For example, for employees you may want to store birth dates but you may not need that for...

Are calculated quantities a part of the Model, View or Controller?

java,model-view-controller,design

Go with your feeling and establish that attribute as a synthetic field in your model. So no extra physical field, but put the derivation function down as a getter. In my opinion that's OK, because that getter does only little more than a really dumb field accessor, and the definition...

Should one forward declare classes from a namespaced library?

c++,design,namespaces,forward-declaration

As @molbdnilo pointed out, there is nothing wrong with forward declaring with namespace. First option is not an option at all, for various reasons I dont want to include header until I have to, forward declaration is always preferred way. Why dont you just provide a header with forward declarations...

Flot Bar Chart design

javascript,design,bar-chart,flot

Here is something like your second picture using another bar dataseries where the start and end of the bars are the same thereby reducing them to lines, you don't need to stack any of the bars just give them the right y-values (fiddle): $(function () { var dataBarsRed = {...

How to eliminate repeat code in a for-loop?

java,design,dry

The parts that changes requires the values of String tagId and String traceId so we will start by extracting an interface that takes those parameters: public static class PerformingInterface { void accept(String tagId, String traceId); } Then extract the common parts into this method: private static void doSomething(Context context, PerformingInterface...

How to store text in a website? [closed]

php,html,design,web

Although is a Silly question I'll answer it, we all have to start somewhere; 1) Use database <div class="profile-info"> <?php echo $db_result->profileInfo; ?> </div> 2) Use plain text $profileInfo = get_file_contents(PATH."/".$userid."/profileInfo.txt"); <div class="profile-info"> <?php echo $profileInfo; ?> </div> 3) Use json $profile_json = get_file_contents(PATH."/".$userid."/profileInfo.json"); $profile = json_decode($profile_json); <div class="profile-info"> <?php...

I can't Run my website [closed]

php,mysql,design

You are seeing this issue because you are using latest version of php and mysql_pconnect() is deprecated in installed php version. Try to replace these code with mysql extension, for example... mysqli_connect(host,username,password,dbname,port,socket); Update your code with following... $Share = mysqli_connect($hostname_Share, $username_Share, $password_Share, $database_Share) or die("Error " . mysqli_error($Share)); ...

Implementing a Command Design Pattern with static methods C#

c#,design-patterns,design,static

Delegates are C#'s built-in implementation of the command pattern. Why re-invent the wheel; use delegates, which support static, pure functions automatically. So you have an event system and those events invoke delegates. You need those delegates to have state though, without creating instances of some class. That's where closures come...

css div gradient shadow/border

html,css,css3,design,shadow

You can fake one, using background gradient and a box-shadow, as well as a css pseudo element to mask the border. Note that if you change the background color of the surrounding content you have to change every instance of #444 .outer { box-sizing: border-box; padding: 25px; height: 200px; width:...

How can i create the basics of a GUI? [closed]

java,user-interface,design

Here's a simple start: public class MainApp extends JFrame{ public MainApp(){ setSize(500,500); //Make the window 500x500 pixels setDefaultCloseOperation(EXIT_ON_CLOSE); //When you hit the x button it will quit setTitle("YOUR TITLE HERE"); JPanel contentPane = getContentPane(); //Add other gui elements to contentPane. setVisible(true); //Make visible } public static void main(String[] args){ new...

How can I achieve this design

css3,design,responsive-design

I didn'tget you exactly what you want... According to your question.. i can suggest... instead of using img tag Use Background Image. Set background image in a class or place it with your coloumn div. Make sure that Image is exact the same size as of column. Thanks....

Mixing DAO and service calls

java,design,architecture

I would turn your question around and say - why not have a service layer for such a method? Is it such a pain to wrap a DAO method like: public class PersonService { ... private PersonDao personDao; ... public List<Person> findAll() { return personDao.findAll(); } ... } Client data...

Approach for designing a program that generates a flat file from dozens of queries [closed]

oracle,design-patterns,stored-procedures,design,plsql

We had similar business requirements. We put the business rules to one table and the queries to another table. The main stored procedure just executed the queries using execute immediate, applied the logic using execute immediate and appended the rows to result files. For complicated queries we used extra stored...

Q: I need idea to display a string with css, jquery or any other techniques (no php)

php,jquery,css,design,styles

Wrap each character in a span, with a classname: HTML: <div id="fieldToSplit">233215334523</div> javascript: var element = document.getElementById("fieldToSplit") var data = element.innerHTML.split(""); var wrappedString = ""; for (var i = 0; i < data.length; i++) { wrappedString += "<span class='shade" + data[i] + "'>" + data[i] + "</span>"; } element.innerHTML =...

segfault in critical section - avoiding deadlock

c++,c,multithreading,design,deadlock

You could catch the signal with a signal handler and handle the resource as you please. I could bealive that with his hint the interviewer meant using the RAII idiom - Resource Allocation Is Initialization. But I am unsure if this applies to signals... ...

Java immutability when defining members in a function called by constructor

java,class,design-patterns,design,immutability

A final variable can be assigned a value only once. The compiler doesn't check whether a method is called only once; hence, final variables cannot be assigned in methods. (In case of the deserialize method the compiler couldn't determine if the method is called only once, even if it would...

Be suspicious of classes of which there is only one instance

oop,design,code-complete

The wording is pretty confusing there, but I believe what's meant is that sometimes a novice programmer might create a whole new type just to instantiate one object of it. As a particularly blatant example: struct Player1Name { string data; }; There we could just use string player1_name; (or even...

Runtime set property from a string

c#,vb.net,winforms,design,runtime

Yes you can! You can use the Microsoft.CSharp.CSharpCodeProvider to compile and execute code during runtime. More information can be found in the answers to this question....

Disable _notes folder that Dreamweaver as a IDE

design,dreamweaver

You need to disable both "Maintain Synchronization Information" and "Maintain Design Notes". See some guidance here.

How to remove white space between border and BackColor?

c#,winforms,design

Look into properties. BorderStyle -> FixedSingle

How to avoid anemic data model? Can repositories be injected into entities?

java,oop,design,domain-driven-design

For a system-wide password expiration policy your approach is not that bad, as long as your UserPasswordService is a domain service, not an application service. Embedding the password expiration policy within User would be a violation of the SRP IMHO, which is not much better. You could also consider something...

CodeBlocks C++ using Classes

c++,oop,design

Besides the syntactical issue that @TobiMcNamobi mentioned, I would consider changing your class to something like the following class Calculator { public: float AdditionFunction(float num1, float num2) const { return num1 + num2; } float SubtractionFunction(float num1, float num2) const { return num1 - num2; } float MultiplicationFunction(float num1, float...

Search box/field design with multiple search locations

python,search,design,search-engine,pyramid

What happens to your search interface if the application changes? This is a very important aspect. Do you add another search type? A search returns matches on the query string. A result set can contain different entities from different types. Then your search/resultset interface could apply filtering based on entity...

Multiple if statements modifying private fields

java,if-statement,design

You're thinking about this too hard. Your set property can only modify one field at a time, so an if/return structure is just overkill IMO. An if/else if structure would be just fine. void setProperty(String aPropertyName, String aPropertyValue) { try { if (aPropertyName.equals(AField.FieldName.getName())) { fieldName = aPropertyValue; } else if...

Web api: Retrieve m2m model vs Retrieve main model

design,views,models,m2m

I wouldn't complicate the matters on a frontend with a new model / api / controller (JobFavourite) in this particular case unless it is absolutely necessary. I would make "favourite" a filter on Job's controller. So, on a filtered job list view you call GET /jobs?favourites=true to get only favourited...

design rule ios app. Is own design allowed or rejected

ios,design

This is totally fine! :) Apple really isn't that strict with its design guidelines... as long as you adhere to the basic UX and UI patterns of iOS and don't greatly violate anything in the HIG (which really isnt the case in your situation) you should be fine! Looking at...

Best approach to implement this design [ios]

ios,uitableview,design,grid,uicollectionview

One approach would be to use a collection view with 2 different kinds of cells; one for the rounded rect shape, and one for the cell with a cut corner. In this approach, the "level cell", as you called it, wouldn't be a cell at all, but a separate view...

Why not reveal the type and identity of the source to the client?

c#,linq,security,design

Though Robert McKee's answer is plausible and raises an interesting point, it is not actually the primary issue that we had in mind when writing that section of the specification. The issue we actually had in mind was this: class C { private List<int> myList = new List<int>(); // Only...

Designing layout android

android,layout,design,linear

While using a separate background xml file is a good idea, i would suggest that you use a drawable instead for background. So you can design your background image with the 'sharp tip' on the left in photoshop or paint.net and set the property android:[email protected]/background_design where 'background design' is the...

In jOOq, why is the connection highly coupled with the statement construction?

java,performance,design,jooq

reuse the same query object for different connection/context You shouldn't do that with jOOQ 3.x. There are a variety of historic reasons why (some) jOOQ QueryParts are mutable. This will change - hopefully - in jOOQ 4.0. Background info here: http://www.jooq.org/doc/latest/manual/sql-building/sql-statements/dsl-and-non-dsl (section about mutability) https://github.com/jOOQ/jOOQ/issues/2198 if the same query...

Can I achieve ordered processing with multiple consumers in Kafka?

design,message-queue,kafka

Yes, you can do this with Kafka. But you shouldn't do it quite the way you've described. Kafka already supports semantic partitioning within a topic if you provide a key with each message. In this case you'd create a topic with 20 partitions, then make the key for each message...

Horizontal line with fade out effect

css,design,less

Reason: Your problem is not with the mixin but the choice of colors. rgba(0,0,0,0) is equivalent to transparent but you already have a background-color set within the selector. So effectively your gradient becomes from #403a41 to #403a41 which just results in a solid line. You can verify this behavior by...

What's the principle to define an interface with dependencies?

java,design,inversion-of-control,method-signature

Is there some principle or best practice to make the choice? Thanks! You can use "Coding complexity rule" as a guidance. Everything that lowers code complexity in both short-term and a long-term way is good. Everything that raises it is bad. If you start injecting everything with a use...

Subtypes of an interface only compatible with a subtype of another interface

oop,design-patterns,design,architecture,solid-principles

It appears you are using Java. If so you can use generics to restrict the type of the parameter in feed public interface Animal<T extends AnimalFood> { void feed(T food); } public class Dog implements Animal<DogFood> { public void feed(DogFood food){ // can only eat dog food } } public...

Does a method like getMyClassOrNewClass violate SRP?

java,design,srp

Short answer, no, but I can see why it looks that way. For a start, it's worth noting that SRP is typically applied to coarser concepts than single functions like whole classes or modules/packages, but the same principles of cohesion do apply to single functions when it comes to maintenance....

How to design abstract listener and its implementation?

design-patterns,design,template-method-pattern

PortListener is an abstract class. Methods listen(), close(), readMessage(), sendMessage() are abstract and should be implemented in the child class. Those methods should create low level operations like opening connection or reading bytes from port. I do not want to mix that kind of details in my base class...

Guaranteed Detection of Temporary->Named Points

c++,c++11,design,move,lazy-evaluation

Since the "internal pointer" method cannot give all the flexibility needed for the deferred evaluation, the typical solution used by C++ numerical libraries is to define specialized classes implementing lazy evaluation mechanisms. The old SO question Lazy evaluation in C++ and its best answers show the basics of such design...

Web Design - What is that style?

javascript,html,css,design,web

The websites are called "single page presentation" or "one page presentation"

Where to populate data? Inside or outside method?

design,data

If one applies Law of Demeter, which is also known as "principle of least knowledge", and Single Responsibility Principle, then one would like to write a code like this: Quotation q = dao.fetchQuotation(someCondition); totalPrice = q.getTotalPrice(); //Computation inside it If the computation is bit complicated and does not involve just...

How to get bar click event from horizontalbar charts of MPcharts in android?

java,android,design,mpandroidchart

That's actually pretty easy, all you have to do is use the OnChartValueSelectedListener and start your new Activity from the callback methods. You can find an example of how that works here. Basically, implement the listener in your class that holds the chart: public class SomeClass implements OnChartValueSelectedListener { Set...

How to enable Design View in jsp file in Web application project in Netbeans?

jsp,java-ee,design,netbeans,web-applications

As far as I know, design view was lastly available in Netbeans version 6.7.1. But in later versions it was unavailable. Yes to edit jsp you can use pellets and drag & drop HTML components. You can search for plugins but I don't think there is one for jsp. See...

Passing Variables to a Golang Package

design,go,singleton

In Go, if your package depends on something external you import said thing. So, unless it's impossible for some reason, you should import the package that instantiates bucket and take it from there, either directly assigning it or in your package's init function. import "my/other/pkg" var bucket = pkg.InitBucket() However,...

Passing control of a drawing window “deeper” into a program?

c++,design,graphics,sfml

I'm afraid you have to decide to do a choice between using a Singleton (GameMaster) that allows access to the main window, or pass a reference to it with your dependent class objects. I personally would prefer the latter (I won't consider adding another constructor parameter to a couple of...

Dynamically-Allocated Implementation-Class std::async-ing its Member

multithreading,c++11,asynchronous,design,shared-ptr

No, the compiler will not optimize away the argument. Indeed, that's irrelevant as the lifetime extension comes from shared_from_this() being bound by decay-copy ([thread.decaycopy]) into the result of the call to std::async ([futures.async]/3). If you want to avoid the warning of an unused argument, just leave it unnamed; compilers that...

What does overflow mean in this case?

android,design,android-actionbar

Overflow is a menu item which groups menu items that are not immediately visible on the ActionBar in a separate menu which needs to be tapped to show the contents. Refer to the Action Bar documentation for more information. In the image above, #3 represents the overflow menu. The documentation...

How should I represent a value of None when a [Flags] enum type doesn't define it?

c#,design,enum-flags

Yes. Since it is a Flags enum, the state of none of the possible values being set is going to be (Buttons)0 (or default(Buttons) if you'd prefer to indicate it in some way that reflects the type directly in your code), whether the designer of the type assigned a name...

Singleton events

c#,events,design

I would fix your error. The general design guideline is indeed the (object sender, EventArgs e) signature. It's a convention and is all about code consistency, code readability...etc. Following this pattern will help other people attaching handlers to your events. Some general tips/answers: For a static event, you should indeed...

what is the difference between view and container view in iOS design?

ios,user-interface,design,uiview

UIView object claims a rectangular region of its enclosing superview (its parent in the view hierarchy) and is responsible for all drawing in that region ... Container View defines a region within a view controller's view subgraph that can include a child view controller....

Designing a high performance network logger solution for a busy server

performance,sockets,networking,design,udp

A very hard question to answer without lots more detail, but in general terms... Get the biggest interconnection you can afford and use between the systems. Using a network card is fine if it has enough bandwidth for your needs, and using a seperate network infrastructure for that connection is...

Good Tutorials for iOS UI Design and Patterns [closed]

ios,user-interface,design

For designers, and people focused about the thorough design of an app: https://medium.com/@mengto/learning-xcode-5-as-a-designer-62b643a3a0f7 (Tutorial from scratch) Hope It Helps....

NoSql beginner dude. Data design and relationships

database,design,nosql

For most nosql databases (key-value, columnar, and document; graph databases are an entirely separate beast), joins are expensive - perhaps even needing to be implemented in application code. For this reason it's preferable to denormalize your tables, Option A preferred over Option B preferred over Option C. Sometimes this doesn't...

How to assure two vectors which will be passed in constructor size equals?

java,exception,design,constructor

Personally, I would make the method throw an IllegalArgumentException: Thrown to indicate that a method has been passed an illegal or inappropriate argument. For example: if (tableNameVector.size() != tableTagIdVector.size()) throw new IllegalArgumentException("tableNameVector and tableTagIdVector " + "must have the same size"); Even though IllegalAgumentException is an unchecked exception, I would...

Getting started: Android application design [closed]

java,android,design

i have used libgdx and andenginee libraries. ANDENGINEE ANDENGINEE is a broad 2D game engine which allows game developers, both experienced and inexperienced, to develop games for the Android platform with ease. AndEngine includes enough functionality to bring any type of 2D game world to life. Most important features of...

Updating composite entities in a RESTful resource

rest,design,restful-architecture

I think that if you want to do partial updates (it's actually your case), you should use the method PATCH. This allows to update either the project without dependencies (statuses) or the dependency(ies) without the project hints. You can notice that there is a format to describe the operations to...

Best way to write a Java function that modifies an object

java,design

The short answer is that there is not a single best way. Different scenarios will call for different approaches. Different design patterns will call for different approaches. You've suggested two approaches, and either one of them might be valid depending on the scenario. I will say that there is nothing...

Setting Full Width to WPF Image in C#

c#,wpf,design,resize

<Grid Name="grid1"> <Grid.RowDefinitions> <RowDefinition Height="70*" /> <RowDefinition Height="30*" /> </Grid.RowDefinitions> <Image Grid.Row="0" Source="c://a.png" Stretch="Fill" /> <StackPanel Grid.Row="1" > .... </StackPanel> </Grid> ...

Where is the best place to put support functions in a class?

python,class,design

You can create a staticmethod, like so: class yo: @staticmethod def say_hi(): print "Hi there!" Then, you can do this: >>> yo.say_hi() Hi there! >>> a = yo() >>> a.say_hi() Hi there! They can be used non-statically, and statically (if that makes sense). About where to put your functions... If...

For a data member, is there any difference between dynamically allocating this variable(or not) if the containing object is already in dynamic memory?

c++,design,stl,smart-pointers,c++14

Using std::unique_ptr here is just wasteful unless your goal is a compiler firewall (basically hiding the compile-time dependency to vector, but then you'd need a forward declaration to standard containers). You're adding an indirection but, more importantly, the full contents of SomeClass turns into 3 separate memory blocks to load...

C++ - need advice on how to properly design a multi-file program

c++,design,header-files

Here are some rules which should work in most situations: Every cpp file has a h-file which is included within the cpp main.cpp includes main.h , Singleplayer.cpp includes Singleplayer.h class definitions and function prototypes are in the header file, the implementation is in the cpp file h: int add(int x,...

Should I be attempting to return an array, or is there a better solution?

c++,arrays,design

I would say that you're over-engineering a big solution to a little problem, but to answer your specific question: Should my program be structured differently, for performance, maintenance or style reasons, such that I would not be attempting to return an array like object? Returning an array-like object is fine....

Android App - Designing for HTC Nexus 9 Screen Resolution

android,design,tablet,screen-resolution

Max width is 1536px, place all your images in the xhdpi folder. You can overwrite whatever you already have in there, even if they're already drawn at the standard width of 720px. They scale the same on both mobile phones and the Nexus 9. Trust me. It just works. Nexus...

Change BackColor of ToolStripItem on Mouse Over [duplicate]

c#,winforms,design,contextmenu

You could use MouseHover and MouseLeave event. It's easy. Just do the following steps: We have a form with these items: http://s3.picofile.com/file/8188577184/Capture.JPG Choose that dark backcolor for ToolStripMenuItem. I choosed black color for fileToolStripMenuItem in my example. Use this for MouseHover event: private void fileToolStripMenuItem_MouseHover(object sender, EventArgs e) { fileToolStripMenuItem.BackColor...

Java: Classes do not find each other in package (factory design pattern)

java,design-patterns,design,factory

There's no problem with your code or packaging, so the problem is elsewhere. How do you compile? I'm guessing you might be doing javac human/Human.java which will not work, since Man and Woman is then not on the classpath and thus not known to the Java compiler when working on...

How to refactor a singleton class and avoid doing the same mistakes again

c#,design-patterns,design,singleton,static-classes

Static classes are considered evil by some people, but that is just an opinion. When I have these questions, I take a look at the .NET-framework: How is it solved inside there? Sometimes a singleton can be refactored to a static class. It depends on the situation. If your singleton...

How to design Validator class in regards to SRP? [closed]

php,design,solid-principles,srp

Whilst I agree that this is primarily opinion based I think that you should have a single class per validator. Otherwise what is the single responsibility of your class? To do all the validation? As suggested you could start out with a Validator that did everything and move towards separate...

Responsive web design tester vs. actual devices [closed]

design

You should solve issues if it comes in real devices. I am not against virtual devices and online responsive design testing tools but those are not accurate always. Also important thing is that your customers , real users will surf site in real device rather than virtual so you must...

Base Class for multiple classes in different projects

c++,inheritance,design

I would define an interface that contains that one shared method. I would then put that interface in it's own project. Then have you concrete implementations reference that project and implement the interface. Something like this.. Repositories.proj IRepository EntityFrameworkImpl.proj Repository : IRepository NHibernateImpl.proj Repository : IRepository ...

Phantom margin/padding on top of parent div

html,css,css3,layout,design

This is because you are not clearing your container element which contains the floated elements. A quick solution would be to add overflow: hidden; on your 2 containers (.navbar-3, .options). The only problem when doing this, is that everything which goes outside the container element is not visible anymore. Another...

What should DELETE /collection do if some items can't be deleted?

rest,design-patterns,design

As a REST API consumer, I'd expect the operation to be atomic and maybe get back a 409 Conflict with details if one of the deletes fails. Plus the DELETE method is theoretically idempotent as @jbarrueta pointed out. Now if undeletable resources is a normal event in your use case...

How to design a dependency list and store it

c#,sqlite,design-patterns,design

I think you can setup the dependencies in code because they are not changed that often, if at all. To achieve what you want, you need to create Quest class with a collection of dependent quests. public class Quest { private List<Quest> quests = new List<Quest>(); // you need a...

How to model data for in-memory processing

java,performance,design,architecture,data-modeling

It totally depends on what kind of data you are working with and what kind of searches you want to perform on it. For example, with hash based structures you can not support partial word searches. You could go for an in-memory relational db if your data is really relational...

Sending and receiving data over Internet

sockets,design,data,send

What I currently do in an application is the following using POSIX sockets with the TCP Protocol: Most important thing is: The most function are blocking functions. So when you tell your server to wait for client connection, the function will block until a connection is established (if you need...

SQL Naming Convention for ID that joins two tables

sql,design,naming-conventions

My recommendation: name the tables in the plural and use the the table name (in singular) plus "Id" for the keys: create table Profiles ( ProfileId int . . ); create table ProfileImages ( ProfileImageId int . . ., ProfileId int references Profiles(ProfileId), ImageId int references Images(ImageId) ); create table...

Generate CSV test data at random from template

design-patterns,design

The main visceral hangup is the mapping of field names to generation rules Why not to map to rule classes directly? You can describe your fields like this (json): [ { "field": "text_description", "rule": "MarkovChainGenerator", "params": { "source": "romeo_and_julliete.txt", "degree": 11 } }, { "field": "salary", "rule": "\\OtherNamespace\\SalaryGeneratory", "params":...

C++, how to call functions when reading their ID number from a Mysql table?

c++,visual-c++,design

It depends on the type of the function (input/outputs) but assuming they are all the same, you can make an array of function pointers. For example: std::vector<void(*)(int)> MyArray; Will declare an array of function pointers returning void and taking one int as parameter. Then you can put the functions you...

Design pattern for corner-case logic without switch and conditional statements

java,design,notifications

Look at the strategy pattern. You can move all your switch statements into a different class. Your class will have an instance of this translation class that will have a method to which you feed the state (all the information) and it will create the output for you. In recalculateSlideDirection...

How to implement solution for Race simulation problems

algorithm,design-patterns,design,data-structures

If you check the Conway's Game of Life you will find that there is a lot in common with the Race Problem. Here is the analogy: The initial state (the seed of the system): Game of Life: initial pattern on the grid. Every cell having the following parameters: x and...

Avoiding semantic coupling with Java Collection interfaces

java,algorithm,oop,design-patterns,design

The general problem is, how does a producer return something in the form that the consumer prefers? Usually the consumer needs to include the preference in the request. For example as a flag - getFoos(randomOrLinked) different methods - getFoosAsArrayList(), getFoosAsLinkedList() pass a function that creates desired List - getFoos(ArrayList::new) or...

Avoid Type Casting During Data Processing

java,oop,inheritance,design,casting

At the end of the day, you're branching based on the subtype (concrete classes) since the logic to validate user input is based on those specific details contained in the subclasses. Generics don't really help you much here since generics are based primarily on applying logic that is uniform across...

How to make REST API private?

api,rest,design

If I were to write a private RESTful API, I probably wouldn't bother to make it RESTful in the first place. By making a REST API private, you're losing one of this architectural style's primary advantages. Implementing an API like this is difficult but in return you get the ease...

Should a class that will run only once contain a static constructor?

c#,oop,design,constructor,static-constructor

Try to avoid the use of static constructors as much as possible. Unlike instance constructors, you cannot actively invoke a static constructor - it is ran when the type is first being used (which may change due to optimalisation or even obfuscation). Also try to avoid doing "work" in a...

Java oop inheritance and interfaces

java,oop,design

I don't see any problems with the inheritance and polymorphism relevant to your design. (Except I would say that squares, circles, rectangles are shapes so maybe use inheritance instead). There might be something about Java syntax you're missing though. Consider any declaration: A test = new B() The first keyword,...

How to make java interface / abstract class that uses per-field equals instead of default equals?

java,design,hash,equals

Such feature is provided by Lombok project. It includes annotation processor which is executed during compilation. It's compatible with Eclipse, maven, ant and so on. You should just annotate your class with @EqualsAndHashCode and it will automatically create the equals and hashCode for you.

How to Edit files using web application

design,web,jython

A simple solution to the concurrency issue you talk about is to save a datetime stamp each time the file is edited from anywhere. Now, if a user tries to save his changes to a file, check the datetime stamp and make sure that the current edit's datetime stamp is...

Design suggestion: Changing the class behaviour

java,design,object-oriented-analysis

Another option is to make the action() method take an array of arguments (like main(...) does). That way ActorTwo could check the arguments to see if its in the special case, whereas the other Actors could just ignore the input. public abstract class Actor{ public abstract void action(String[] args); }...

Does 'api/SomeEntity/ForOtherEntity/{otherEntityId}' break REST?

rest,design,web-api

No, your URLs does not break any principles of REST - for the simple reason that REST is not concerned about URL structures. I would recommend reading one or two of the "REST" books mentioned at http://www.infoq.com/articles/rest-reading-list to get started on REST. If you further more read through the original...

Is checking of object type really always sign of bad design?

c++,design,types

First off, it's not always a sign of bad design. There are very few absolutes in "soft" things like "good" or "bad" design. Nevertheless, it does often indicate a different approach would be preferable, for one or more of these reasons: extensibility, ease of maintenance, familiarity, and similar. In your...

Attr value is declared in two different libraries

android,design,attributes,styles

The easiest fix for this is to just rename the attribute in one of the libraries. To do that you have to: Download the source code of one of the libraries and add it to your project. Now you have to rename the attribute in the source code you just...

Custom shape of a SeekBar in android application

android,design,android-seekbar

Similar to this question here How to make custom seek bar in android? You're not going to be able to do that with the default slider. You're going to have create a custom view. Here's some resources to get you started. http://www.mokasocial.com/2011/02/create-a-custom-styled-ui-slider-seekbar-in-android/ http://developer.android.com/training/custom-views/create-view.html Edited to add this other resource the...

C++ Avoiding down-casting or variants

c++,design,variant,downcasting,visitor-pattern

Option 1: "fat" type with some shared / some dedicated fields Pick a set of data members that can be repurposed in a token-type specific way for your "some token-type-specific data. Literals have a value, symbols have a symbol type, and identifiers have a name." struct Token { enum Type...

Match status bar colour with most predominant colour of art Material Design Android

android,design,whatsapp,material

I'm not sure I got it, but you can extract dominant colors in an image with the Palette support library. It lets you extract, from a given Bitmap, six colors that you might need: Vibrant Vibrant Dark Vibrant Light Muted Muted Dark Muted Light See also here for reference....

Modern webdesign and effects?

layout,design,contao

I am sure you understand what responsive web design(RWD) is. when I scroll down, the navigation resizes und stays fixed, how can I do this. Basically what is happening here is when you scroll beyond the position of the header, a class 'stickyHeader' is added to the #header element. The...

designing “pretty” user controls [duplicate]

c#,wpf,design,charts,user-controls

In order to fulfil your requirements, you will need to create a CustomControl. You can find a basic tutorial in the How to Create a WPF Custom Control page on WPF Tutorial.net, but you will need to do more than shown there. You can find a better tutorial in the...

How to handle this cycle dependency?

javascript,design-patterns,design

I do not think UI layer should really call component layer if some event happened. It should send an event. You could use Observer pattern here. After it sent an event, it should not care if it was handled or not. When component needs to draw itself, I guess here...