Tag Info

Hot answers tagged

16

Pascal had subrange types, i.e. decreasing the number of numbers that fit into a variable. TYPE name = val_min .. val_max; Ada also has a notion of ranges: http://en.wikibooks.org/wiki/Ada_Programming/Types/range From Wikipedia.... type Day_type is range 1 .. 31; type Month_type is range 1 .. 12; type Year_type is range 1800 .. 2100; ...


7

Ada also is a language that allows limits for simple types, in fact in Ada it's good practice to define your own types for your program to guarantee correctness. type MyType1 is range 1 .. 100; type MyType2 is range 5 .. 15; myVar1 : MyType1; It was used for a long time by the DoD, maybe still is but I've lost track of it's current use.


6

See Limiting range of value types in C++ for examples of how to create a range-checked value type in C++. Executive summary: Use a template to create a value type that has built-in minimum and maximum values, which you can use like this: // create a float named 'percent' that's limited to the range 0..100 RangeCheckedValue<float, 0, 100> ...


5

I think that converting to Maven is the best thing that you can do in general, and it would allow you to use the Maven Dependency Plugin. It shouldn't be hard to convert: move your project files into the "standard" Maven locations, and create <dependency> entries for all of the JARs that are currently there. Barring that, take a look at the JDepend ...


5

Some restricted form of your intention is to my knowledge possible in Java and C# through a combination of Annotations and Dynamic Proxy Pattern (there exist built-in implementations for dynamic proxies in Java and C#). Java version The annotation: @Target(ElementType.PARAMETER) @Inherited @Retention(RetentionPolicy.RUNTIME) public @interface IntRange { ...


3

Take a look at some code quality and code indexing tools. FishEye For starters, you could use FishEye, which would index your code and allow you to quickly query for code from all the repositories so you can keep a bird's eye view of the whole codebase. For instance, you could search for a given file (but also for a file's content, including a method ...


3

You cannot cast since they are different types; the language does not allow you since Java has a very strongly typed system. You can do this however: Integer fiveInteger = Integer.parseInt("5"); String fiveString = String.valueOf(5); In Java you have these types of legal casting: Primitive casting - casting between two primitive types int fiveInt = 5; ...


2

If you are already over with your OCPJP 6 exam, you are now eligible to take Java EE certifications. From my own experience, I suggest you to take the following exams to deepen your knowledge: Oracle Certified Expert, Java EE 6 Java Persistence API Developer Oracle Certified Expert, Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer ...


2

Google just recently announced that it is moving Android development to IntelliJ. There is a reason for this. I have been using Eclipse as an environment to teach courses for the past few years in both C++ and Android/JAVA. I have watched the quality of Eclipse deteriorate to something approaching unusable. In Fall, 2012, I adopted Eclipse Juno for my ...


2

There are three licenses for sub-components of the MorphAdorner library that might restrict its use in your application. The Gate and NGramJ libraries (contained in MorphAdorner) use the LGPL license. The LGPL effectively requires that it must be possible for a user of your application to replace those libraries (and possibly the MorphAdorner library, ...


2

Appears as pretty naive attempt to convert RGB to luminosity with some heuristic use of average brightness as a threshold. You can find correct RGB->LUMA formulas along the lines in this discussion: http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color


2

One of the reasons I think this discussion comes up repeatedly is because it seems like a serious pain-in-the-ass to take an object with all the data you need and convert it to an object that looks identical or nearly identical to the one you are handing off. It's true, it's a PITA. But there are a few reasons (besides those enumerated above) for doing so. ...


2

According to me, passing a persistable POJO, like for instance a bean managed by JPA, is not THE good practice. Why? I see three main reasons: Potential issue with lazy collections. http://java.dzone.com/articles/avoid-lazy-jpa-collections Entity should contain behaviour (in contrary of an Anemic domain model) You may not want to let your UI call some ...


2

The problem in your approach arises from your construction of the regex. If you look at Java Docs for the Pattern Class, you see that \w matches just word characters: [a-zA-Z_0-9] It sounds like you just want to match any characters between semicolons after a defined key with any number on spaces in between. The right pattern for this is the following: ...


1

Well, depending on the complexity vs. load of your application, Spring Batch may or may not be a good solution. This is strictly a personal opinion, but I've found that, while Spring Batch let's you quickly prototype some batching mechanism (you only have to implement the business logic, all the batching mechanism comes out of the box) it can prove slow if ...


1

1) First and foremost understand this is not an easier way to approach any problem. PHP has a bad reputation for being nasty and tangled but I feel it has been made that way over the years because of its leniency. It is very easy to get lost in that "damn it's so easy" mentality and lose hold of your standards. 2) Read accepted and respected standards from ...


1

You have 2 options: 1. by git way: use submodules. Here is a documentation how git manage submodules git submodules. I personally didn't use it but it looks to fit your problem. 2. by maven way: in maven it is not mandatory that your root project (configuration) to be hierarchically the parent directory of all your projects. You can have a structure like ...


1

What you are looking for is a "utility" package. This may include classes with static utility methods used all over the application. Common utility classes are String operations, Date/Time, etc. Your validators could be a subclass of the utility package, but personally I would put them in the domain in a higher "common" directory. Refer to this answer for ...


1

Create a Scanner for your InputStream, Reader, File, String, etc Iterate over the tokens If a word doesn't already exist in your Map, add it with a value of 1. If a word already exists in the map, increment its value. When done, close the Scanner. Iterate over the map and display. Your solution and @parsifal's take a couple of unnecessary steps that are ...


1

Having a jsp as a controller is wrong for multiple reasons. Development mode should not dictate application architecture or in other words if you need hot deploy choose a proper tool/server for that. Adding an intermediate controller (jsp) create many data handling problems than it solves. For instance how do you handle passing request parameters? How do you ...



Only top voted, non community-wiki answers of a minimum length are eligible