« first day (609 days earlier)      last day (3412 days later) » 

3:22 PM
I smell a defrag coming on...
 
 
@rolfl Already used, all small tools, etc. that add up
And no defragging on SSDs ;)
 
4X performance improvement in this answer:
2
A: N-Queens - Brute force - bit by bit

VeedracThe thing that looked the slowest was int mask = 0; for (int i = 0; i < depth; i++) { int queen = candidates[queens[i]]; mask |= queen; // previous queens cover this column.... mask |= queen >>> (depth - i); // previous queens cover this // diagonal...

 
@rolfl Seems like my code solves NQueens(8) in 32 ms. Definitely slower than your code, as I expected. I did manage to re-use quite a bit of old code though. I realized that NQueens is just another CSP (Constraint Satisfaction Problem), not too different from Minesweeper ;)
 
Ahh damn. Must be nice @skiwi. I hear the boot times are practically nonexistent.
 
3:29 PM
Hey, I've got a question about the security of a piece of code that I didn't write (namely the password generator of lasspass). I know that codereview isn't the place to ask it, but I'm not sure if the security site is the correct place
 
Do you maintain the code @NathanMerrill? Do you understand it?
 
I understand it, but I don't maintain or work on it at all
I want a "is this code secure" answer
 
Okay, yeah. You're right then. CR isn't the place. Thanks for knowing that!
It might be on topic for Security. I've seen those kinds of questions there.
 
@RubberDuck Yup ;)
 
jealous
 
3:40 PM
Why is it considered so unreasonably by microsoft that I might want to open 2 excel files next to eachother
Nooo, I can only view one!
 
I can have two instances of Excel open.
 
Yes you can. You just need to open a second instance of excel and use the open dialog inside of Excel.
 
Or just double-click to open the two separate files.
 
I don't think I've used the open dialog in.. 5 years?
 
Now... You won't be able to use your personal.xls macros in the second instance though....
 
3:42 PM
@Hosch250: then you can only view one at a time, if you doubleclick them from explorer
 
They open in two windows.
 
but only one can be open.
 
Not for me.
 
You can view, arrange windows.
 
Split them on your screen by dragging them until your cursor hits the edge.
 
3:44 PM
ah, I have office 2010
maybe that's a difference
 
I don't think so - I had Office 2010 for a while too.
 
Okay, that view - arrange windows thing worked
sort of
 
It might be, but I don't think so.
 
now I have both sheets open in one excel instance
 
Yup. If you're on a dual monitor though, it's better to create a second instance of excel.
 
3:45 PM
 
So let me ask @JeroenVannevel, what is it you're really trying to do? =;)-
 
Alright, let me make a screencapture
How do I do this
 
1
Q: Function pointer default arguments workaround

prestokeysTask: Suppose you have the following: class Thing { public: void foo (int, double = 3.14) const {std::cout << "Thing::foo(int, double = 3.14) called.\n";} void goo (int, double = 1.5) const {std::cout << "Thing::goo(int, double = 1.5) called.\n";} }; void function1 (const T...

 
"Suppose you have" @captainobvious?
 
Like that?
 
3:51 PM
@rolfl That's what I want. But not what I can
 
OK, you can
Go to start -> Microsoft Office -> Excel 2010
THen do it again ....
now you have 2
 
Is that your music you are listening to... ?
 
yeah, but I forgot how to properly configure the broadcaster
okay, so that way you have indeed multiple views
 
OK, and I see it works ;-)
 
3:55 PM
the way I have it now is like this:
which you get by opening them from explorer
only one can be active at a time
 
Apparently the all-in-one-excel instance helps with DDE (makes it possible0
 
I see
Well, not how I would prefer the standard mode to be
but okay, solved. Thanks!
song in question, by the way: youtube.com/watch?v=x_uAHeSVI1c
 
np... but, you are right, it should be easier to see/do
 
Yes. It should..
 
0
Q: OOP PHP best practices

user1871949I've worked with PHP for a few years now and have a degree of understanding about classes / objects but I've never written my own until now. In that vain then, I'm looking for a bit of confirmation of the code below and that I am doing things properly before I go any further. Any advice / critiq...

 
4:11 PM
@CaptainObvious OOP PHP? You mean PHP OOP?
@CaptainObvious Horrible title, absolutely no description about what the code does, 2 upvotes? Sorry, I have to give it a down-vote for now.
 
Can we get one more CV on this before someone posts an amazing answer and we all have to question what exactly makes for hypothetical code again?
0
Q: Function pointer default arguments workaround

prestokeysTask: Suppose you have the following: class Thing { public: void foo (int, double = 3.14) const {std::cout << "Thing::foo(int, double = 3.14) called.\n";} void goo (int, double = 1.5) const {std::cout << "Thing::goo(int, double = 1.5) called.\n";} }; void function1 (const T...

 
I was going to, but @SimonAndréForsberg beat me to it.
 
That one hurts me to close. It's clear, concise, reusable content... And wholly hypothetical.
 
@Hosch250 Moahaha
@RubberDuck Which part of foo and goo do you find 'clear'?
 
Not so much the code itself exactly, but the question @SimonAndréForsberg
 
4:25 PM
I'm really confused now.
 
It's also unlike most hypothetical code in the fact that it works. It accomplishes a task (albeit trivial). Just makes you step back and wonder a bit.
 
It doesn't compile, though.
The OP said so.
 
But for every question like that one, there are 100 that aren't.
Ahh. I missed that @Hosch250.
 
Does anyone here know C# good?
 
@Hosch250 he gave one example which wouldn't compile, but I believe the others do.
 
4:27 PM
OK.
 
No. He has two ... That^
Wouldn't say I know it good, but I do alright.
 
I'm really having a hard time understanding part 3 of this answer: codereview.stackexchange.com/a/75540/34073
 
@Hosch250 depends on what "good" is. I've used it, but wouldn't say I know it well. I normally refer to @Mat'sMug when it comes to C#
 
0
Q: Is this a good DSL design for F#

robkuzI am building a small DSL for iOS' autolayout feature obviously I want to have a typesafe way to define autolayouts instead of doing VSL. I came up with the following //in reality this will be a Xamarin/iOS View type View = | View type Constraint = | Max of int | Min of int ...

 
I know, he's the expert on this.
 
4:30 PM
What part are you having trouble with @Hosch250. His update is pretty clear to me.
 
Yeah, I'm just confused.
Where does he want me to store the data values then?
In GlobalVars?
He didn't like GlobalVars?
Does he basically want me to write an interface between GlobalVars and ViewModel, like an API?
 
Well... Yes and no.
Yes in that there probably should be a boundary between global vars and view model, but "no" in the sense that it shouldn't matter where the data comes from. So long as it adheres to the interface.
I also don't care for your GlobalVars class, but I haven't quite figured out how to kill it.
The newest version does look much better though.
 
Me either - I have to have those variables hardcoded somewhere, I think.
 
You could have removed that GlobalVars thing with my answer from a few days ago
 
@JeroenVannevel I'm sorry, I'm all confused.
 
4:34 PM
I explicitly decoupled the presentation from the internal workings in my solution
you'll have that comment every review if you keep it in there
 
OK.
But still, where am I going to keep my list of typeof(datapage) then?
 
You don't.
 
Like I said, it can't go into the resources file.
Then how do I load my pages?
 
You'll have to look back at the chat conversation from yesterday or 2 days ago
 
Well... At a glance, the resource file is a good thing I think, but I don't think you're using it properly. You're using a string to return the same string from the resource file...
 
4:36 PM
by manually writing each line
not by looping over it
 
Self note: Don't make a typo for an integer parameter. Solving NQueens with size 9 is significantly different from size 91.
4
 
Lol
 
So it would all be in one huge NewSelection method in my ViewModel?
 
133 ms vs. Stack Overflow Error.
6
 
4:52 PM
@JeroenVannevel You mean something like this? pastebin.com/uUcf6tmE
 
OK.
You know, I actually had it like that originally.
I didn't keep it like that because I thought I might as well keep all the constant items in a single file together.
Thanks for being so patient.
@JeroenVannevel You mentioned the resource file making it easier to support multiple languages.
I currently have all my data in files like this: codereview.stackexchange.com/questions/74887/…
Should I change this to make it easier to support multiple languages somehow?
 
euhm
Not quite sure what you mean but if you're talking about making your xaml pages localized: msdn.microsoft.com/en-us/library/dd882554%28VS.95%29.aspx
 
OK, so basically I am doing this right, but I would just need to create n different versions of them for the different languages and localize each set?
 
mmmm
n different versions of what?
 
5:00 PM
Of my data/tutorial pages.
 
no
you create one page with all the stuff on it
but instead of hardcoding content like "click here", you refer to your resourcefile with key "click_here" (or something like that)
Then you can start the app with locale "en-US" and it will take the english resource file
which will result in "Click here" as text
but if you start it with locale "fr-FR", it will say "Cliquez ici"
 
I see.
 
one view, multiple resourcefiles
 
OK, great.
The only language I know is English, but maybe if/when I get another computer, I'll translate it with Bing/Google, set my second computer to a different language and take the screenshots, and find someone to proofread it (or set up something for my users to report bad/incorrect grammar/etc.).
 
You can just set the locale programmatically: Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-Fr");
no need to change your computer's settings
or even to get a second computer
 
5:06 PM
I mean, I don't have Office installed in those languages for the screenshots.
And I won't be able to work with all the buttons and stuff labeled in a different language.
 
1
Q: Bulls and Cows in Python

AvneriumI have recently written this little Bulls and Cows game in Python: """Play Bulls and Cows.""" import random NUM_DIGITS = 5 class IllegalNumber(Exception): """An exception to raise when the class Num has an instance of an illegal number.""" pass class Num(object): """Represent a...

 
5:28 PM
Just got multiple menus working.
 
5:49 PM
Hello.
 
@MannyMeng Ahoy.
 
Hey.
 
Hi.
 
Hiya
 
Anyone have an idea for a fun programming project?
 
5:53 PM
Reworking an existing, huge project?
 
I meant a small project that I can finish in a day.
 
Solve the Knight's Tour.
 
@MannyMeng Reprogram the whole Windows file system in utf-8.
 
@Morwenn Really?
 
@MannyMeng I doubt it can be done in a day.
 
5:56 PM
@Morwenn I doubt it's fun.
 
@SimonAndréForsberg Depends on what you consider "fun" :D
Many wouldn't even consider that programming is fun :)
 
@Morwenn Ah right, that was before the "finish in one day" requirement :p
 
@Hosch250 Good idea... (maybe)
 
I did, in Java.
It took two days because I didn't know about backtracking then.
So I had to ask on SO.
 
Oh.
 
5:58 PM
ermph... Conway's Game of Life
that's a 3 hour thing.. from scratch..
well if you know what you're doing that is ;)
 
@MannyMeng Have you done a turtle graphics?
I did an ASCII turtle graphics in a couple hours in Java.
Several hundred lines of code, though.
8
Q: ASCII Turtle Graphics

Hosch250In my college Java course, I wrote an ASCII Turtle Graphics. My professor said the only thing he could suggest was to turn the turtle into a class and create an instance of it (I hadn't because we hadn't covered classes yet). What do you think? package javaapplication74; import java.util.Scan...

 
@Hosch250 what's several??
 
0
Q: Need feedback with a ping function in Python

flamencoBelow is a piece of code which takes a list of IPs, pings the hosts and returns (prints) the list for "Alive" and "Dead". Any feedback on what can be done better is welcomed! Mainly, speed and reliability! Would you accept it as a production code? try/except blocks, logging? Cheers and Happy New...

 
Write the most correct min function possible. That's a tough challenge by itself.
 
418
 
6:03 PM
@Morwenn ?? most correct?
 
I though it was 5xx, but not quite.
A few hundred, anyway.
 
@Vogel612 There are whole articles dedicated to writing such a function :p
 
that's a nice small thing there ;)
@Morwenn hmmm maybe I didn't quite understand... but.... what does a min function do??
 
@Vogel612 Return the min of two numbers.
 
@Morwenn anything else?? like.... special type constraints?
 
6:05 PM
Or the min of a set of numbers. Your pick.
 
if (a < b) return a; else return b;
return a < b ? a : b;
 
Here is a little article on the subject :p
5 parts, an everything isn't covered in it.
 
@Morwenn If using an infinite datatype, it's easy
 
0
Q: Another Rock Paper Scissors in plain JavaScript

MohamadOutside of the jQuery DSL I've hardly ever written any JavaScript. I never bothered learning JavaScript until a couple of months ago. After a slow start I got stuck in and created this game. As some may know I usually program in Ruby. And this is proving to be a great obstacle because I'm instin...

 
6:25 PM
0
Q: Optimization of SQL query

php_nub_qqThe task is to select all posts tagged with a certain tag, along with other tags the post may have, given as text rather than id Table posts CREATE TABLE `posts` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` text NOT NULL, `text` text NOT NULL, `date` datetime NOT NULL, PRIMARY ...

 
@MannyMeng what about ?
 
@RubberDuck ?
 
@Morwenn return Math.Min(a, b);
nailed it
 
@JeroenVannevel Thanks again.
I got everything working, and I'm moving from the practice app to the main app now.
 
no probs
I'd give you my bankaccount number but I don't know it myself
 
6:30 PM
After this, I need to redo my forward/back button logic.
Me either :)
My parents have that.
Don't worry, I wouldn't steal anything.
I'll give you a bounty, though, if I make it at least 50 over 2k by Jan 12.
 
@JeroenVannevel Is it able to return the min of two instances of some user-defined number class implementing a comparison (less than) function?
 
euh
whistle
 
:D
 
44 mins ago, by Manny Meng
Anyone have an idea for a fun programming project?
What about Simon Says? It was a community challenge recently.
 
@Morwenn doesn't that come down to properly implementing Comparable?
at least in java terms?
 
6:38 PM
@Vogel612 Looks like it.
 
26
Q: Prebash Challenge - 2014 - Simon Says - Now Complete

rolflIn Memory of Ralph H. Baer - 1922-2014 - co-inventor of the "Simon" game. This round is now complete! Simon Says will be the challenge this time Simon Says: +17 score Resistor: +12 score Calculator: +11 score Challenge completes when Winter Bash Starts - Happy Winter ...

 
yeah, just implenting Comparable in Java or IComparable / overloading the operator in C#
 
@Morwenn might be interesting to see how that handles primitives....
 
the function itself won't be very special
it's the custom class that does all the work
 
0
Q: Transposing rows and columns for file contents

Ganesh KamathThis program transposes rows and columns for file contents: import string intermediate="" with open("key_Value.txt", 'r') as fin: for line in fin: intermediate+=line.strip() + "\n" i = intermediate.splitlines() heading = [] values = [] splitstring = " " for s in i: if "{" in s: ...

 
6:58 PM
I think I'm going to re-write my entire VM from scratch.
I just tried to merge it and everything exploded.
I'm surprised a raptor didn't come through the wall.
2
 
You've gotta watch out for those raptors......
 
A really vague crash error too - type initializer for MainPage.xaml through an exception.
It compiles, though, which complicates the problem.
Oh, it didn't find my resource map.
 
0
Q: Is it stupid to use reduce two times in a row in lisp?

aduchThe actual question: Is it okay to use reduce two times in a row on the same list? (it is not exactly the same list as it has been reduced, but I hope you get my point) First of all I'm new to lisp (I currently use clisp and sbcl), there probably are huge mistakes in this code so any guideline...

 
7:20 PM
One of my favorite titles: Why this code ugly? how to improve?
 
If that's what C# looks like, it feels like it won't be too hard to learn :)
 
@Gemtastic since you're coming from a java mindset... yes and no.
 
-1
Q: file transfering in client-server

user2987243I wrote a program that client can connect to server but server doesn't send files name to client. who can help i? this program must does this: first server send to client name of file for downloading. then client send to server name of file that it wants to download and then server send file to c...

 
The conventions are so subtly different it's killing you at first
@CaptainObvious kill it with fire...
 
@Vogel612 Well, it's not java. If anything it's probably more similar to how the JVM was programmed, but it doesn't look very foreign. It's just the theory behind it I'd need to learn.
I just love the feeling of being able to read code in different languages, and actually understand what they do.
 
7:39 PM
I never formally learned C#, I just knew Java
If you know Java, you can get going with C# without a problem
you'll just have to get used to the fact that your code is automatically cleaner, shorter and easier to read
 
Sounds fun :)
 
@JeroenVannevel hrmph... no
or rather... depends
I don't like C#, because properties, classes and Methods get confusing with all the pascal-case..
java conventions makes clear what you are looking at just by different naming conventions ..
 
compare:
Class.Property.Method();
and java-like (with a public final "property" field):
Class.property.method();
 
Oh boy. @CaptainObvious will be bringing by a gem in a minute.
 
7:43 PM
My attempt in solving Knight's Tour:
 
I particularly dislike certain C# indentation. Shifting a function's enclosed contents by several spaces from the left just looks ugly in my opinion.
 
Exception in thread "main" java.lang.StackOverflowError
I used recursion...
 
or even more distinct: SomeClass.SomeProperty.ItsMethod(); vs. SomeClass.someProperty.someMethod();
 
It's a matter of perspective @Vogel. I see variables in the middle of a method call there...
 
@Hosch250
 
7:44 PM
@MannyMeng if you did tail-recursion you could derecurse
 
Not to mention in Java you'd most often be using SomeClass.getSomeProperty().someMethod()
 
@MannyMeng Yes?
 
Bracing is a bit subjective too. I think it's a matter of what you're used to.
 
@RubberDuck so you'd prefer: var prop = SomeClass.someProperty; prop.someMethod();?
 
no, he means that you suddenly have a variable-style-notation in your chain
 
7:46 PM
No. That's not what I'm saying. I'm saying the lower case Properties and Methods look like variables to me.
 
that's because a field is camel-case...
 
How did you solve the Knight's Tour?
 
ohh..
@MannyMeng not at all yet... but I'd suggest backtracking instead of recursion
 
A rare occurrence: a code-only answer by a new user actually got improved. Feel free to determine if it's good enough to remain.
 
I used a heuristic and backtracking.
 
7:47 PM
I tried backtracking...
And failed.
 
What language are you using?
 
@Jamal not sure if it's fine to have a rant like this without the code to demonstrate how to do it better...
but deleting the python code was the correct step..
 
Java
 
I used Java too.
Want to see my code?
I can post it for a review.
 
Never mind.
I GOT IT WORKING!!!
 
7:49 PM
@Vogel612 I suppose that user may not be able to write C# code anyway. It looks like the entire answer is based on Python knowledge.
 
OK.
 
I meant it in an excited way.
 
-2
Q: Finding the maximum of all minimum shortest paths?

pkmI've been practicing on the INOI server lately, however I've not yet solved even a single question. I studied Graph Theory for the first time last week and decided to do the FREETICKET problem using Djikstra's Algorithm (here). I've tried to solve the problem innumerable times, but am still not ...

 
Obviously.
 
@Jamal lol they rolled back... I went ahead and did one myself, as well as putting a comment in there.
 
7:52 PM
@Vogel612 Great comment. If he/she does it again, I may need to lock it.
 
@JeroenVannevel I've read that if you want to have a C# class span multiple files, you have to use the partial keyword.
 
You read correct
 
What happens if you don't, you just name the classes the same?
 
you get a namespace conflict
 
you'll get a compilation error
 
7:56 PM
OK, I didn't compile it, but I could access the values in the other class.
 
well if you keep them in separate namespaces it's actually fine ;)
 
unless they are in a different level of the namespace hierarchy
 
I did it by accident.
 
but then they wouldn't work as partial classes in the first place
 
No, they were both in the same namespace.
I just wanted to know.
 
8:04 PM
> Now if the under-20 set would stop deleting my answer, I can move on with my life.
 
@Jamal Was that pythonguy?
 
Yep
 
Oh.
Lovely.
 
All in a day's work as a mod. And I guess I'm not over 20 after all.
 
I wonder why they couldn't get on with life with a deleted answer.
 
8:11 PM
Ya know, I disagree with the whole "answers have to be in the same language" thing. Hardcore.
If it illustrates the point, what's the problem?? I would call that rollback vandalism.
 
0
Q: Knight's Tour with Backtracking

Manny MengWhen someone suggested me to solve Knight's Tour, I did so with backtracking and recursion. It takes a lot of time to solve even a 8x8 board: NA1 NC2 NE3 ... NC5 NA6 Time used to solve: 7079726 nanoseconds That seems quite a lot, but the most interesting part of my algorith ...

 
8:30 PM
@JeroenVannevel Do you mind if I ask a question about Resource files?
It works as long as it is named Resource.resw, but not for Titles.resw.
 
8:50 PM
@RubberDuck the problem is that OP is not guaranteed to know what certain stuff in a language does. and to illustrate the point: you wouldn't want a haskell answer to some procedural vba question, right?
 
I don't see the difference between haskel on vba and psuedocode on vba personally.
 
pseudocode usually just illustrates the algorithm.. haskell is an implementation already
 
Maybe I'm just more flexible about it. VB is very different from C# is very different from Ruby and all.
 
and I wouldn't expect vba to have something like reduce() or map()...
 
But if you don't know Haskell, it might as well be psuedo code.
 
8:53 PM
anyways, I'm off ;)
 
See ya!
 
Haskell is like magic to me
Even though I managed to understand some of it on a simple example!
But I have no clue how to code an entire application in Haskell
 
9:28 PM
0
Q: Need help solving "Alien Languages" in Hackerrank

sshI'm trying to solve https://www.hackerrank.com/contests/monthly/challenges/alien-languages and it works for the sample test case. However, it fails on the other test cases and I'm not sure why my logic isn't working. In the program free denotes the letters that don't have restrictions. N = int(s...

 
@Hosch250 I think you can use any name you want but renaming the resource file might be a problem though
If there's one thing I dislike about developing for android in Java is the whole casting system and method overloads for each type
getInt() instead of get<Integer>() or (TextView) findViewById(R.id.smth) instead of findViewById<TextView>(R.id.smth)
so.. primitive
 
@JeroenVannevel That's because Android sucks
Yet, at the same time, it also apparently awesome
But despite that it also still sucks
 
9:44 PM
It took me an hour to figure that problem out.
I'll check that.
@MannyMeng I responded to your comment.
@JeroenVannevel It will accept it only as long as it is named Resources, whether I create a new on, whether I rename, or what.
 
Mhhm
Well, it's been a while since I've actually used it myself
 
I'll look it up on the web.
 
@JeroenVannevel it is safer to do typecasting explicitly than doing it inside the method using generics.
 
why is that?
 
if the typecasting would be done inside the method and done with generics, you would get a compiler warning.
you always get a compiler warning when you typecast to a generic type, I believe.
I can't really explain why that is the case though.
 
9:56 PM
warning, but not an error
because you might pass in a type that isn't compatible
but that's the responsibility of the caller
 
This webpage states that it should be call Resources.resw: msdn.microsoft.com/en-us/library/hh694557.aspx
 
either the cast fails inside the method through the passed type or it fails at the next level when you explicitly cast it to your wanted type
 
It took me a couple hours to realize what was wrong :(
 
instead of the ugly Object that you receive
 
@JeroenVannevel correct, not an error. Never said it was an error.
 
9:57 PM
Yeah. I just don't see why it would be safer to do the cast outside the method instead of inside it
They both have the same amount of risk, it's just that one scenario shows a warning because it's easier to detect
unless there's another aspect I'm missing
 
Honestly, I think getInt() is cleaner than obj.get<Integer>(); (which btw technically needs to be written as obj.<Integer>get(); )
 
meh
Maybe when you look at it in isolation
but if you use .get<T> then you can also pass in custom objects
 
@JeroenVannevel and you can't typecast to custom objects otherwise??
 
well you can, but then you again have to write that explicit cast instead of a nice <Type>
which in turn forces you to surround it with brackets if you want to use the object inline
 
0
Q: Brute Force algorithm in C- How can I make it faster?

Tom JacobI'm still very much a beginner, so I don't really know much about best practices or the speed of any particular C functions. You'll notice that I included a "cs50" library --> this is from a MOOC I'm taking, all it does in this program is allow me to use their "bool" data type. I realize I don't...

 
10:01 PM
The whole idea of a statically typed language is to have concrete objects to work with
 
@JeroenVannevel "nice" is opinion based. What is it about a <Type> that makes it more "nice" than (Type) ?
 
If your API returns Object for everything then that is against the statically typed mindset
 
@JeroenVannevel agreed there.
getInt-like methods might be an issue about primitive types. Having an int is better than an Integer
 
yeah, that too
generics for primitives is ugly in Java
 
the method call could also have been LinearLayout layout = findViewById(R.id.yada, LinearLayout.class); and typecasted inside the method (without warnings)
 
10:04 PM
Eh, I'm not a fan of passing the type as an argument
it's too meta for that
 
I'm not a big fan of it always, but sometimes it makes sense and is useful
 
@SimonAndréForsberg If Android resources was using generics, then it would indeed do the cast inside the findViewById method and if incorrect it would actually lead to a runtime error still
 
@skiwi yes, I know.
 
LinearLayout layout = findViewById<>(R.id.yada); can actually work
 
@skiwi you wouldn't even need the <> there.
 
10:06 PM
It's better as LinearLayout layout = (LinearLayout)findViewById(R.id.yada); imo
@SimonAndréForsberg Correct there
It's just that Android didn't implement it or bothered to make an attempt to add it later
 
I think it makes sense that findViewById returns a View and that you have to do the typecasting yourself.
 
I don't think so
 
10:25 PM
0
Q: Is it always necessary to use getters and setters?

MattDs17I'm working on a game with Slick2D and am just working through the Entity class. I'm making every variable protected and then accessing them with getters and setters. Yet it feels like I'm over-complicating things and it is more efficient to simply let some of these properties be public. public ...

 
10:39 PM
@CaptainObvious The question may be okay, but this is a pretty bad title.
 
10:53 PM
@CaptainObvious Is it always neccessary to have a good title?
 

« first day (609 days earlier)      last day (3412 days later) »