|
Pollyanna posted:why the hell is creating a copy of an object in Objective-C so goddamn complicated NSArray *array = [otherArray copy]; Is hard?
|
# ? Oct 5, 2013 13:56 |
|
|
# ? Jun 5, 2024 21:21 |
|
no but its the ugliest loving syntax
|
# ? Oct 5, 2013 13:57 |
|
nm
|
# ? Oct 5, 2013 13:58 |
|
git clone trooper posted:no but its the ugliest loving syntax if you have a problem with ugly syntax objC isn't for you
|
# ? Oct 5, 2013 15:42 |
|
Notorious b.s.d. posted:if you have a problem with ugly syntax objC isn't for you is it weird that I think objc's syntax looks loving wonderful in comparison to the abomination that is c++?
|
# ? Oct 5, 2013 19:38 |
|
not that Ill ever write anything in objc because I dont own any apple products but still, in comparison to the pile of poo poo that is c++ it looks like heaven
|
# ? Oct 5, 2013 19:39 |
|
how have you been here 13 years and never probated? mods?
|
# ? Oct 5, 2013 19:57 |
|
PrBacterio posted:is it weird that I think objc's syntax looks loving wonderful in comparison to the abomination that is c++? this x1000 [object pleaseDoAThingWith:[SomeClass objectWithFile:filename]]; is so much better than C++. I always chuckle when C++ programmers complain about objective C's use of square brackets while C++ code looks like someone just randomly mashed the angle bracket, colon, and underscore keys on their keyboard.
|
# ? Oct 5, 2013 20:22 |
|
Doc Block posted:this x1000 sorry did you stroke out mid post because wtf is that poo poo
|
# ? Oct 5, 2013 21:18 |
|
objc syntax just takes some getting used to. it's a little verbose but that verbosity allows it to be somewhat self documenting, so it's pretty nice. once you get used to it and understand why the syntax is the way it is, it'll make a lot more sense. at first i was like 'wow all these method calls are really weird' but i had no idea what an object was so that was a lot of my problem
|
# ? Oct 5, 2013 21:25 |
|
objc gives you the oop of c++ bullshit without the impossibly esoteric syntax magic that you can't debug objc just makes whats really going on more transparent without the vague syntax idk i dig it
|
# ? Oct 6, 2013 00:21 |
|
FamDav posted:sorry did you stroke out mid post because wtf is that poo poo It's just a shorter version of SomeClass *foo = [SomeClass objectWithFile:filename]; [object pleaseDoAThingWith:foo]; The tendency to make Objective C method names really long actually helps readability a lot and makes the code self-documenting to a large degree. It also makes it nice when you want to do something but don't know the exact method name, since you can usually guess the method name. Or guess the first part of it and see what Xcode's autocomplete suggests.
|
# ? Oct 6, 2013 00:41 |
|
java is better cause the syntax is readable and not stupid
|
# ? Oct 6, 2013 00:43 |
|
LOL java object = ObjectFactoryFactory().newFactory().newObject() not stupid at all
|
# ? Oct 6, 2013 00:51 |
|
i really wish apples documentation would list all of the most common methods that you might call on a class/instance instead of just the methods defined in that class. like if you want to set the display value on NSThing which has an inheritance tree 6 classes deep you have to go up the class tree to figure out how to perform this incredibly common action
|
# ? Oct 6, 2013 00:55 |
|
its a shame you can't code iOS apps in visual studio, and that xmarin poo poo don't count
|
# ? Oct 6, 2013 00:59 |
|
Hmm yes let me use a not-Objective-C language and a not-LLVM compiler. NOT -borate
|
# ? Oct 6, 2013 01:04 |
|
Doc Block posted:Hmm yes let me use a not-Objective-C language and a not-LLVM compiler. hmm yes lets rewrite our entire codebase every time we want to port to a platform
|
# ? Oct 6, 2013 01:18 |
|
NOT - people who get poo poo done
|
# ? Oct 6, 2013 01:21 |
|
itym people whose apps look like poo poo on every platform
|
# ? Oct 6, 2013 01:25 |
|
Doc Block posted:LOL java hi ive written thousands of lines of java and never needed a factory i guess what im saying is lol you're in the write thread fucko
|
# ? Oct 6, 2013 04:08 |
|
Bloody posted:hi ive written thousands of lines of java and never needed a factory i guess what im saying is lol you're in the write thread fucko java attempts to follow and encourage object-oriented programming principles the most fundamental principle of object-oriented programming is dynamic dispatch but what if i want to dynamically dispatch even the construction of an object? i won't know which class i need until runtime java constructors don't do that, hence factories
|
# ? Oct 6, 2013 04:20 |
|
once you understand solid, factories are a natural corollary
|
# ? Oct 6, 2013 04:31 |
|
idk just dont write such awful code and you wont need such awful hacks
|
# ? Oct 6, 2013 04:40 |
|
youre all just writing poo poo garbage crud apps anyways
|
# ? Oct 6, 2013 04:40 |
|
i was going to say that i don't but then remembered that i spent the last week working on a poo poo garbage crud app most of my work is more interesting i swear Bloody posted:idk just dont write such awful code and you wont need such awful hacks how do you feel about singletons
|
# ? Oct 6, 2013 04:47 |
|
singletons are fine in certain situations like, if you have an object that there should never be more than one of, use a singleton
|
# ? Oct 6, 2013 05:36 |
|
when you can't have more than one, use a singleton...the only example i can think of is R. R interpreter state is process-global so it's impossible to have more than one. if u try then u'll probably segfault even then it might make sense for the public interface to be regular objects that coordinate their access to the singleton if you shouldn't have more than one, just only make one instance
|
# ? Oct 6, 2013 05:43 |
|
sometimes you're programming with idiots and you need to sledgehammer them into only having one instance
|
# ? Oct 6, 2013 14:31 |
|
Or you're writing in Objective C, where singletons are pretty common. Like, you find out if a file exists by asking the NSFileManager class's defaultManager singleton.
|
# ? Oct 6, 2013 15:37 |
|
IO access points should usually be singletons (ex: db connection/session providers) and configuration classes/parameters should be singletons either cause their read only, so why have more than 1, or cause you need to have a single point to lock for doing global writes (really that's just more IO).
|
# ? Oct 6, 2013 15:41 |
|
but wouldn't a static class for config objects work just as well? i use static classes all the time for stuff that only needs to exist in memory once. and singleton for io connections sorta makes sense but only if you need blocking operations, but why block on db access?
|
# ? Oct 6, 2013 15:51 |
|
or is java singleton done in a way I'm not understanding? i am c#.net
|
# ? Oct 6, 2013 15:52 |
|
singleton makes use of static to enforce a single instance of an object globally
|
# ? Oct 6, 2013 15:52 |
|
its not about blocking complete access to the db, it would be like maintaining a single connection pool and feeding back free connections rather than having every bit of your code constantly opening new ones all over the place. the pool manager and the datasource config would be singletons. and a static class for config would be a singleton
|
# ? Oct 6, 2013 15:55 |
|
Bloody posted:sometimes you're programming with idiots and you need to sledgehammer them into only having one instance nah the hard part is convincing idiots to not use singletons
|
# ? Oct 6, 2013 15:58 |
|
Doc Block posted:Or you're writing in Objective C, where singletons are pretty common. Like, you find out if a file exists by asking the NSFileManager class's defaultManager singleton. nsfilemanager isn't a singleton
|
# ? Oct 6, 2013 16:02 |
|
Shaggar posted:its not about blocking complete access to the db, it would be like maintaining a single connection pool and feeding back free connections rather than having every bit of your code constantly opening new ones all over the place. the pool manager and the datasource config would be singletons. got it, different terms for the same result.
|
# ? Oct 6, 2013 16:11 |
|
Nomnom Cookie posted:nsfilemanager isn't a singleton NSFileManager is a class. defaultManager is a singleton instance of NSFileManager, though you can make your own non-singleton NSFileManager instances if you need to do something weird. So I guess it's more of a shared, global instance, but 99.999% of programs only use the global instance, so it's effectively a singleton. Doc Block fucked around with this message at 17:32 on Oct 6, 2013 |
# ? Oct 6, 2013 17:29 |
|
|
# ? Jun 5, 2024 21:21 |
|
JewKiller 3000 posted:java attempts to follow and encourage object-oriented programming principles this explanation is both concise and correct
|
# ? Oct 6, 2013 19:08 |