Say I have a class in Android, Account, instanced to represent the current user's account. This shows up everywhere. I could pass it through Intents. I could put it in a subclassed Application. I could used Shared Preferences. If we assume that just about every activity will need it what is the best approach?
The Big Programming Thread - Page 925
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
WarSame
Canada1950 Posts
Say I have a class in Android, Account, instanced to represent the current user's account. This shows up everywhere. I could pass it through Intents. I could put it in a subclassed Application. I could used Shared Preferences. If we assume that just about every activity will need it what is the best approach? | ||
Blisse
Canada3710 Posts
| ||
Bog
Netherlands49 Posts
Joined. Didn't know about the existence of this event. I really liked Project Euler as well. I find it amazing to see how some people can solve these problems in under a minute. The Memory Spiral problem (day3) took me at least two hours. | ||
![]()
shz
Germany2686 Posts
On December 04 2017 19:00 Bog wrote: Joined. Didn't know about the existence of this event. I really liked Project Euler as well. I find it amazing to see how some people can solve these problems in under a minute. The Memory Spiral problem (day3) took me at least two hours. Yeah that is astonishing. I only glanced over day 3 and I'll probably need more than that. We'll see when I find time. | ||
mahrgell
Germany3942 Posts
If you have no troubles doing squares of 3 digit numbers in your head you can even do it without any tools. For the second part i admit i wrote a rather brute forcish solution, but unlike project euler problrms those problems here are not performance sensitive do it still solves it instantly. | ||
LightTemplar
Ireland481 Posts
| ||
Bog
Netherlands49 Posts
On December 05 2017 03:28 LightTemplar wrote: I used a mathmatical approach to day 3 p1 so I didnt have to generate the spiral, looks like the second part makes a similar approach impossible. Is there something more elegant than drawing the whole spiral out I'm missing? I did the same for the first part (under the assumption the travel distance should be calculable for any positive index number), but ended up rewriting all new code for the second part where I just generate the spiral. I don't think a generalized sequence can be extracted from the second spiral ![]() | ||
Acrofales
Spain17852 Posts
| ||
Excludos
Norway7969 Posts
On December 05 2017 05:16 Acrofales wrote: Haven't done anything yet (and probably won't at all), but isn't the spiral solvable using straightforward dynamic programming? it's solvable by just using some basic algorithms. However part 2 is not solvable like that. So if you end up programming part 1 (which I did) you only have to do some small adjustments to finish part 2. That said my solution was rather crude. I'm not sure "30 seconds of code running" counts as "below 1 millisecond" ![]() | ||
Liebig
France738 Posts
I'm using OCaml myself | ||
mahrgell
Germany3942 Posts
On December 05 2017 06:12 Liebig wrote: What programming language are you guys using for the AoC ? I'm using OCaml myself Julia For Project Euler I went with C++ for most of the time, but also switched to mostly Julia lately, except for stuff where it felt easier to create performant solutions in C++. | ||
Excludos
Norway7969 Posts
On December 05 2017 06:12 Liebig wrote: What programming language are you guys using for the AoC ? I'm using OCaml myself I was considering doing it in Fortran or lisp because I hate myself, but there isn't enough hours in the day. Ended up doing it in good ol' c++. | ||
![]()
shz
Germany2686 Posts
| ||
raNazUra
United States10 Posts
Joined. Thanks for pointing this out, I hadn't seen it before. I'm using Python, none of these first 4 problems were close to performance dependent enough for me to leave my comfort language. | ||
Hanh
146 Posts
| ||
WarSame
Canada1950 Posts
On December 04 2017 15:17 Blisse wrote: Use a dependency injection framework and keep the Account object alive as long as the user is logged in. I've been reading about dependency injection for the last little bit and I fail to see how it lets me implement a session any differently than just creating a regular object would. Could you clarify that? | ||
![]()
NovemberstOrm
Canada16217 Posts
The test is 1 hour and 5 minutes | ||
Excludos
Norway7969 Posts
On December 05 2017 10:33 Hanh wrote: Does anyone know what the Ascii art on the main page is? I believe it represents a maze that you walk through as you complete each step | ||
![]()
shz
Germany2686 Posts
This years flavor text: + Show Spoiler + The night before Christmas, one of Santa's Elves calls you in a panic. "The printer's broken! We can't print the Naughty or Nice List!" By the time you make it to sub-basement 17, there are only a few minutes until midnight. "We have a big problem," she says; "there must be almost fifty bugs in this system, but nothing else can print The List. Stand in this square, quick! There's no time to explain; if you can convince them to pay you in stars, you'll be able to--" She pulls a lever and the world goes blurry. When your eyes can focus again, everything seems a lot more pixelated than before. She must have sent you inside the computer! You check the system clock: 25 milliseconds until midnight. With that much time, you should be able to collect all fifty stars by December 25th. | ||
Blisse
Canada3710 Posts
On December 05 2017 12:24 WarSame wrote: I've been reading about dependency injection for the last little bit and I fail to see how it lets me implement a session any differently than just creating a regular object would. Could you clarify that? Are you unsure about dependency injection or dependency injection as it relates to scoping? Just got this Google coding challenge terminal thing in the browser, it's weird. | ||
| ||