The Joys Of Programming

I might need to pick your brain on the signed jar in the fat jar. That could be a potential issue for us down the road.

Cyranix wrote:

Today: learned how to use Guice for method-intercepting annotations and for assisted injection (a.k.a. autowired factories). Once tboon helped me get past an initial hurdle with how to fit various frameworks together [thanks again!], I've found Guice to be elegant and powerful.

Guice is fantastic, I really love using it. I especially love that when I have default implementations of interfaces I can annotate the interface using @ImplementedBy(Whatever.class) and Guice will automatically figure out the mapping when I @Inject. When overriding the default is needed, I can do so by providing the altered implementation to the injector so it autowires up the non-default implementation. Really handy for things like DAO implementations where almost always you have a default implementation of an interface.

Also, if you haven't looked at it yet, check out Google Guava. Lots and lots of good utility stuff (generic containers, functional-style programming) in there. Google Java libraries are almost always fantastic, I can;t think of one I have used that was not.

SixteenBlue wrote:

I might need to pick your brain on the signed jar in the fat jar. That could be a potential issue for us down the road.

I can give you the short answer on that if you're using Maven -- put the signed JAR on the classpath using this snippet in the POM file (it goes under build/plugins section):

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.2</version> <!-- I think this is a suitable version, but double-check --> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <!-- I know that paths relative to $JAVA_HOME will work, and I'd imagine that absolute paths are fine, but I don't know if other locations can be used to resolve relative paths. --> <Class-Path>lib/ext/signed_thingy.jar</Class-Path> </manifestEntries> </archive> </configuration> </plugin>

Then change the scope of the corresponding dependency to provided.

tboon wrote:

Also, if you haven't looked at it yet, check out Google Guava. Lots and lots of good utility stuff (generic containers, functional-style programming) in there. Google Java libraries are almost always fantastic, I can;t think of one I have used that was not.

Yeah, Guava is great -- it's included in Dropwizard. Sometimes I find myself liking the Apache Commons utilities better, so I don't sit firmly on one side of the fence but try to be consistent when I choose one library to provide a specific bit of functionality.

Cyranix wrote:

Yeah, Guava is great -- it's included in Dropwizard. Sometimes I find myself liking the Apache Commons utilities better, so I don't sit firmly on one side of the fence but try to be consistent when I choose one library to provide a specific bit of functionality.

I like Apache Commons for a lot of things. But Common Collections is outdated and the maintainers haven't seemed all that interested in generifying it. Guava is, so wins on that count. Generally, I view Commons as a fallback if Guava doesn't have what I need, which is a lot. Guava doesn't cover the ground Commons does (nor does it claim to).

I still prefer Spring over Guice due to the fact that Spring lets you wire things up outside the code. Maybe Guice has changed since I last looked at it, but I find it almost pointless to use annotations to define how code is wired together. Might as well just call the setters yourself intead (though Guice would be more elegent than this).

Starting a big UI project today. One of the major customer-facing components of our software, and by default the first thing they see. It's all specced out so I'm just implementing it, but it'll be the biggest WPF project I've worked on since starting here in October. Looking forward to diving into it. Except for the part where I have to work with Infragistics data grids. Not looking forward to wrestling with that.

kazar wrote:

I still prefer Spring over Guice due to the fact that Spring lets you wire things up outside the code. Maybe Guice has changed since I last looked at it, but I find it almost pointless to use annotations to define how code is wired together. Might as well just call the setters yourself intead (though Guice would be more elegent than this).

We had this conversation at work recently too, and here's the main reason I prefer annotation:

It's all controlled in the class you're working in. If I use setters, I have to go to some other place in the code and wire up the setter call. With annotations, it's all right there where I'm working right now. I honestly don't see a lot of benefit in wiring things up outside of the code. I'd rather keep it simple and keep it local.

SixteenBlue wrote:

We had this conversation at work recently too, and here's the main reason I prefer annotation:

It's all controlled in the class you're working in. If I use setters, I have to go to some other place in the code and wire up the setter call. With annotations, it's all right there where I'm working right now. I honestly don't see a lot of benefit in wiring things up outside of the code. I'd rather keep it simple and keep it local.

It just causes you to write tight coupled code, something that dependency injection is supposed to prevent. I agree with the downside of wiring things up outside the code, but I feel that the flexibility it provides is important. I am not saying Guice is bad, just that I still prefer Spring (even in its bloated form).

kazar wrote:
SixteenBlue wrote:

We had this conversation at work recently too, and here's the main reason I prefer annotation:

It's all controlled in the class you're working in. If I use setters, I have to go to some other place in the code and wire up the setter call. With annotations, it's all right there where I'm working right now. I honestly don't see a lot of benefit in wiring things up outside of the code. I'd rather keep it simple and keep it local.

It just causes you to write tight coupled code, something that dependency injection is supposed to prevent. I agree with the downside of wiring things up outside the code, but I feel that the flexibility it provides is important. I am not saying Guice is bad, just that I still prefer Spring (even in its bloated form).

That's fair. I use it more to make my life easier and to remove boilerplate than to enforce decoupling.

I'm tired and it's really late, but why isn't this compiling?
Argument 2: cannot convert from 'out ITemplate< T >' to 'out ITemplate< Foo >'
Make is a generic function, it shouldn't care about the type until I call Make< Foo >(name,out result) yes?

edit: found this http://stackoverflow.com/questions/5...

public bool Find(string name, out ITemplate&lt; Foo &gt; sst) { return somenames.TryGetValue(name, out sst); } public bool Find(string name, out ITemplate&lt; Bar &gt; itif) { return othernames.TryGetValue(name, out itif); } public bool Make&lt; T &gt;(string name, out T result) { ITemplate&lt; T &gt; itt; bool wasitfound = Find(name, out itt); // it can't compile this right here, why? ... }

I'd like more information on what you're trying to do in context. I don't think this is a good approach to whatever you're doing.

Dang, I can't do this in C# either.

Type some_type = someobject.GetType(); SomeGenericFunction < some_type >(someobject);

What the hell

ClassA someobject = new ClassA(); Type sometype = someobject.GetType(); // this works sometype = ClassA; // this does not

Totally forgot about the typeof operator.

public bool Make<T>(string name, out T result) where T: Foo, Bar { ... }

might work, as might making Find part of an interface that takes a type T, and passing that interface to the function. You could also have Make return a Tuple<bool, T> to avoid whatever problem ref/out has with variant types.

A bit more context might help, but it looks like a design problem to me.

RolandofGilead wrote:

I wish to create objects at run-time

Have you looked into Activator.CreateInstance(Type type)?

I have seen this used for mapping interface templating.

I wish to create objects at run-time based on some templates and I need to find the template based on its name
so if I want to build an object of a particular type I can just call

public interface ITemplate&lt; T &gt; { bool Make(out T objectBeingCreated); } private Dictionary&lt; Type, Dictionary&lt; string, ITemplate&lt; T&gt; &gt; &gt; allOfMyTemplatesAreStoredHere; // doesn't compile bool BuildMeAnObject&lt; T&gt;(string name, out T objectBeingCreated) { Dictionary&lt; string, ITemplate&lt; T&gt; templateCollectionIndexedByName = allOfMyTemplatesAreStoredHere[typeof(T)]; ITemplate&lt; T&gt; actualTemplate = templateCollectionIndexedByName[name]; actualTemplate.Make(out objectBeingCreated); }

One workaround is to change ITemplate to
public interface ITemplate { bool Make(out object objectBeingCreated); }
and just doing a cast.

edit: each key T within allOfMyTemplatesAreStoredHere represents a ConcreteBuilder if you will, and each instance of a template represents a Product that is initialized with specific values.
Like one template would create a Square with sides of length 4 and another would create a Square with sides of length 8.

Got my first Node.js setup running with lots of new-to-me toys! I went with Express as my web app framework with middleware for CSS preprocessing (Stylus + Nib), HTML templating (Handlebars using hbs view engine), and livereload -- plus I'm writing my server logic in CoffeeScript and sticking nodemon in front of the app to restart the server after I edit it.

My only ever-so-slight pain point is that I don't seem to be able to trigger a live page reload when I edit a Handlebars template (maybe due to not rendering client-side?) -- I feel like if I could fit Grunt in somewhere, the regarde task might be able to trigger livereload, but I haven't grasped that yet.

JobInterviewQuickSort() is very familiar to me.
IMAGE(http://imgs.xkcd.com/comics/ineffective_sorts.png)
Hover-text below

Spoiler:

StackSort connects to StackOverflow, searches for 'sort a list', and downloads and runs code snippets until the list is sorted.

Haha, I was just going to post that!

I really like my new job. Made my first svn commit today.

You know all that stuff coders say that starts with "if I ran this place..."?

This place is hitting a lot of those things for me. Still week one, but feeling pretty right.

I saw something today that stackoverflow is the #1 source of documentation as far as people's search preferences.

Spoiler:

StackSort connects to StackOverflow, searches for 'sort a list', and downloads and runs code snippets until the list is sorted.

[/quote]

That's basically how all software engineering design is done now.

bandit0013 wrote:

I saw something today that stackoverflow is the #1 source of documentation as far as people's search preferences.

It is a large portion of how I learned to code and how I learned how python works.

boogle wrote:
bandit0013 wrote:

I saw something today that stackoverflow is the #1 source of documentation as far as people's search preferences.

It is a large portion of how I learned to code and how I learned how python works.

Boogle's post closed as Not Constructive.

So, update on the guild thing. I'm getting close enough to publicly launching that I'm quite terrified. I've created a sort of white paper that defines the problem I'm trying to solve and some of the benefits of sponsorship. If anyone cares to take a look, I always value feedback.

http://www.swcguild.com/whitepapers/SWC_Sponsorship.pdf

*Legion* wrote:
boogle wrote:
bandit0013 wrote:

I saw something today that stackoverflow is the #1 source of documentation as far as people's search preferences.

It is a large portion of how I learned to code and how I learned how python works.

Boogle's post closed as Not Constructive.

Oh God I hate reading that, especially when I google a subject and find exactly what I want on Stack Overflow only to have my knowledge acquisition thwarted by some wanna-be software engineer with a god complex and a tiny dick. Who are the jackasses who close down questions all the time? They should not be allowed to ruin perfectly good discussions.

It's been awhile since I've done relational DB stuff, and I either forgot or never learned that doing an "INSERT INTO table SELECT a,b,c,..." query requires you to list the columns in the table you're inserting into, or it'll just use the columns in defined order, even if the columns you select have names that perfectly match those in the destination table.

We couldn't figure out until now why my positive/negative/neutral review count was rotated one space from the consultant's results, but with 112 distinct genders, this will certainly be the most progressive analytics system in existence, though apparently only for customers with single-digit ages.

So, update on the guild thing. I'm getting close enough to publicly launching that I'm quite terrified. I've created a sort of white paper that defines the problem I'm trying to solve and some of the benefits of sponsorship. If anyone cares to take a look, I always value feedback.

http://www.swcguild.com/whitepapers/...

Problem #1: 404 not found.

Minase wrote:
So, update on the guild thing. I'm getting close enough to publicly launching that I'm quite terrified. I've created a sort of white paper that defines the problem I'm trying to solve and some of the benefits of sponsorship. If anyone cares to take a look, I always value feedback.

http://www.swcguild.com/whitepapers/...

Problem #1: 404 not found. :D

Case matters: http://www.swcguild.com/whitepapers/swc_sponsorship.pdf