It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have this project that has functions to load different chapters of a book. (Ex. loadChapter1)
My thinking was that I will call the functions to load up every chapter when the app launches. But by the time I am done with the program, there would be a huge amount of chapters. It's only loading up lots of NSStrings.
Would that make the program slow to initialize or even crash the program?
My functions are declared in AppDelegate.h using ( -(void)loadChapter1 ). The way I call it in AppDelegate.m is using [self loadChapter1].
If this is not a good way, this there any other way to do this?
You're better off trying something, seeing if it works well, then making changes (and possibly asking questions here) if it doesn't rather than asking a question like this at the outset. For performance questions in particular, the accepted wisdom is that you shouldn't worry too much about performance (memory and CPU usage) while initially writing a program, but rather should do performance optimizations as needed after you've got the program working.
That said, my first approach to this would be to load each chapter as it's requested. So, don't load all the chapters in the book every time the app launches. Rather, load a chapter when the user turns the page to that chapter or selects it in the table of contents (or whatever applies to your app). That way, you don't waste time and memory loading chapters that before they're actually going to be used.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I recently was asked this question in an interview and would like to hear the answer from you people.
I discussed about code resuability and security that can be achieved by encapsulation and inheritance but the interviewer did not seem satisfied.
He insisted on how exactly an application user is benefited by using applications developed on the principles of oop.
Depends. Purists (and morons) will apply abstraction to every possible bit of code they generate or come across. This is completely unnecessary in something as simple as a direct, simple MySQL call from within a tiny bit of PHP, to log site accesses, for instance.
However, generally OOP can save you plenty of cycles if applied systematically to big data involving lots of information shuffling, like sorting hundreds of rows of data on every page access. It's a matter of when to use OOP and when to just write procedural code. OOP takes time and effort and is maintainable by experienced programmers, but you need to ask yourself if it is worth all that extra hassle on a tiny snippet of code that does one thing internally.
There are plenty of good articles out there (http://berryllium.nl/2011/02/getters-and-setters-evil-or-necessary-evil/) that help you to understand WHY OOP is sometimes unnecessary and in fact harmful.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm new to threading in .net and its hard to find good examples that I can use.
I'm reading articles here. Managed Threading Best Practices But I'm still not clear. Right now I have a program where I'm trying to have two threads running at the same time but doing different things. I have one thread working doing what it is supposed to, but when I start my second thread (I name it PrintThread) I have PrintThread and Main Thread running the same lines of code, Should I be looking into the syncLock statement to avoid this?
Cannot evaluate expression because we are stopped in a place where garbage collection is impossible
This is just a debugger diagnostic, telling you that it can't display the watch expression. You are apt to get this problem when you use Debug + Break All to break into the debugger.
In general, yes it can be quite difficult to debug code when two or more threads are running the same code. Breakpoints stop being effective since every thread will hit them. One possible solution for that, beyond using unit tests (recommended!), is to use Debug + Windows + Threads. You'll see the active threads listed in this window. You can right click them and select "Freeze". That freezes the thread until you "Thaw" it again. Which lets you focus on debugging only one thread.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a cocoa application,I want to get the time from the application startup to it startup succeed.And then post the time to my server.Can someone give me some tips?
Define your starting point (e.g. application:didFinishLaunchingWithOptions:) and ending point (e.g. viewDidLoad on the main view controller). Create a class (with + messages) that has start and stop calls. Once you get stop, post the time to your server (asynchronously of course).
all this measuring wont take into account the runtime loading.
classes loading & !frameworks loading
it happens before your main and even instruments won't correctly profile it
although it will show that an amount of time passes between 'Run App' and main!
this load can have a considerable influence on your time especially when frameworks have been swapped out / you do a cold start
tried at WWDC WITH apple engineer and we could reproduce times ranging from 3s(normal time for my app) to 10(when we used safari before!)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
With last version of iOS Apple has implemented Automatic Reference Counting for Objective-C, but I don't understand as works.
Automatic reference counting inserts retain and release messages into your code for you at compile-time, following the normal conventions. So it's exactly as if you did the memory management yourself manually, except that the compiler is smart enough to be able to write that bit for you, and much less likely to make a mistake.
So it's not garbage collection, it's more like a (very simple) form of static analysis. And you still get overwhelmingly deterministic memory management and little overall change in runtime costs, as per the caveats raised by Catfish_Man below.
Automatic Reference Counting implements automatic memory management for Objective-C objects and blocks, freeing the programmer from the need explicitly insert retains and releases. It does not provide a cycle collector; users must explicitly manage lifetime instead.
Read this spec - Automatic Reference Counting
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Hi there: I was looking at a few videos, etc and I just cant help but wonder why Pex usage seems to be so low?
Are there any problems that are not obvious, or is it just a licence issue?
It's a very new tool and to work really well you need to use Code Contracts as well. It also catches a lot of issues like possible integer overflows that a lot of developers think they can just ignore. Pex is amazing and will take off eventually but it has a learning curve so it's going to take some time to percolate through the .Net ecosystem.
I've used it on a few new development projects and it has saved me two major bugs (not caught by normal unit tests) that would have taken at least a week to track down and fix normally plus a few smaller issues so I'm a big proponent of Pex. That said it takes a lot of work to get it producing good results on an existing code base of any size so how cost effective it is will need to be determined on a project by project basis.