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 am working on one of big project.so that's why my application contains a lot of coding. Interesting thing about this project is that it contains only one mainview and this mainview contains 25 subviews, each subview contains UITableview.so problem for me is that if I declare all these subview and uitableview in mainview along with different function which I need for every subview it create confusion. Now to make it easy I want to create separate class for each subview, but I am not familiar with how to access all these classes in my mainviewviewcontroller. Still if some one not able to understand my problem then please visit this link. http://chris-software.com/index.php/2009/05/02/passing-data-between-classes/
It seems from your comment that you already have coded something like you have mentioned in your problem, and now, you trying to make your code scalable and making it separate as zoul has suggested.
As zoul has mentioned, There isn't any exact solution to your problem, as your problem is also not exact, or say specific.
Unfortunately, It is not fully possible what you are trying to achieve, as you have mentioned in your comment. But, Let me try to give you some hint that you may find useful when refactoring your code.
Decide what data needs to be shared among the different classes.
Decide View Controllers for your application. By saying this I mean, number of View Controllers, as your application might need. It also may be possible that you can accomplish the task with less number of view controllers.
If size of shared data is considerably large then, I would suggest that you would SQLite or CoreData for that, whichever suits your need.
Specific query is welcome.
Best of luck :)
Additional Note: Try to follow the design pattern provided by Apple, most importantly in the initial phase of SDLC.
First, certainly do split the code into separate controllers or views, otherwise you would enter the world of pain. Second, it's hard to answer your current question here on Stack Overflow, because this is a question about architecture and answering it properly requires a longer discussion about your problem; there is no ready solution.
Generally, in such cases you want to build the individual screens or views as separate controllers with interfaces that allow them to be connected together as needed. (Try hard to design the individual controllers to know as little about the others as possible.) Then you can have one class that will create all the components and connect them together. There are many particular tools that can help with that, especially the UIViewController containment API introduced in iOS 5.
Going by your problem of using the same code in a new/different class time to time, re-usability is the key.
But to get this correct you must follow the "Loose Coupling and High Cohesion" principle.
Essentially, you need create each sub-view like a component by itself, which performs a specific task and is not aware or dependent on external factors like its parent etc.
Lastly, I feel the main problem you are facing trying to resuse code is because you are using IB for wiring up function to UI events.
I would suggest using target and selector properties for wiring as this will ease resuability and also keep your code discreet and cleaner.
You can read more about coupling and cohesion here Loose Coupling and High Cohesion
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I was reading someone's code where I came across Knockout and MVVM. I did some reading on both topics, but I'm still confused as to what problems they really solve, most likely because I just haven't built applications large enough to come across the problems that this framework/architecture solves.
I spent some time to understand this sample code -- http://knockoutjs.com/img/homepage-example.png -- from the Knockout home page. I was hoping if someone could explain to me what the same code would look like if Knockout were not used, and how that could be problematic.
(SO may not be the right platform for this question, so please let me know if there's some other Exchange that's more appropriate).
Thanks!
From 10,000 Feet
Knockout provides two-way data-binding between a view written in HTML and corresponding properties and functions on a viewmodel written in JavaScript.
Imagine you have an HTML view called contacts.html and a JavaScript viewmodel called contacts.js. Those two together would make a module, and Knockout would be the glue that binds them together.
MVVM stands for Model View ViewModel. I addressed the latter two above. The model is simply a JavaScript representation of a particular corner of your world, say, in this case, a Contact.
So, bringing together the above, we might have (in terms of directory structure):
models\contact.js
views\contact.html
viewmodels\contact.js
You might instantiate your model inside your viewmodel, and then bind your view to the viewmodel using Knockout.
MVVM simply provides for a great way to separate concerns and maximize reuse. As an example of reuse, you could bind your contacts view to many different contact viewmodels, depending on context. The context could be the size of the client device, a user's authorization profile, a "community" versus a "premium" version of your application, and so on.
Modifying by improvement any of the components of MVVM can be done in relative isolation without adversely affecting the application as whole. Hence the value of separating concerns.
Does that make sense?
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Not sure if this is the best place to ask or not but if it gets closed down oh well. I am in computer programming and starting on my first work term. I will be doing 2D game programming for iPhone in objective C. I was just wondering if you had any tips for learning how the code works on a big project. In college I have never worked with something in terms of this scope. I am used to a project with maybe a dozen source files while what I'll be working on has hundreds. It is very overwhelming for me.
Any Tips would be appreciated. Thanks very much
This is how I do it. Opinions and methods may vary.
Generally speaking, I find the best way to learn about a system is to go through the code while the app is running.
Pick a significant place in the UI (the startup screen, some other screen).
Find the class for that view. Generally just ask a senior developer. Developers are happy to give a pointer (no pun intended) to someone who wants to learn by himself instead of having to explain everything.
Place a breakpoint in that class and run the app in Xcode until you hit your breakpoint.
Then start tracing in there to see how things happen.
Repeat the process at different spots in the app and soon you'll get a general idea of how the app works. Then it's a lot easier to catch the details.
If the system is really enormous (like an enterprise app that runs on multiple systems), then a diagram showing all the architecturally significant pieces would probably help. For an iOS app, it's probably not needed.
Good luck...
I am a 3rd year computer engineer who has done four work terms, and I can offer the following :
Some general advice:
Compartmentalizing your approach is still very useful on a big project, as in a small one. The more specific parts you focus on at a time, the easier it will be to understand them. This is not always practical due to interdependence of programs, but it is still possible to, say, work on the graphics portion alone, or the character's movement algorithm, etc. You should know that in the past that it was possible for an educated person to know the sum of human knowledge, but that is impossible today. Even senior engineers/programmers have specific areas of expertise, and other areas where they are fuzzy. Find what you most enjoy/are talented at, and devote time to that.
A basic foundation is important. Study the basic ideas of loop structures, classes, methods and the like, and know them like the back of your hand, so when applying them across languages/platforms, all you need to do is refresh yourself on the syntax. The same basic ideas apply across a range of languages.
Most of all, do not panic. It is your first work term, and you are assigned mentors/supervisors, as well as working with a team. Doing it alone would be difficult, so network well with your teammates/superiors so you can all learn from each other, divide the work, and lessen the stress on yourself!
Good luck! :)
Short Answer :
Read less, do more, then read when you get stuck. In my opinion, that's the best way to learn any new language and also someone said :
"We learn by doing, there is no other way".
Long Answer :
Rule 1: Relax.
Rule 2: You gotta understand that this is not easy stuff to master. That is why people who do get paid really well. If you had an idea you could bang this stuff out in a couple of weeks with you need to dump that. Plan to spend months working up on it.
Rule 3: Understand that the Apple API is HUGE and it is always evolving. There is enough content to learn something new Everyday.
Rule 4: The fewer programming languages you've had to learn, the harder it is to learn new ones. You will learn slower than someone else who has learned half dozen languages/APIs already.
Rule 5: Don't be afraid to use repetition and brute force. I think the thing that slows novices down is not learning the behaviors and methods of common foundation classes like NSString, NSArray, NSDictionary etc.
Rule 6: As a learning exercise, copy-pasting might not be the right thing to do. If there's an Apple example of how to do something, rather than copy-pasting I tend to rewrite it manually. I find it sticks better in my mind.
Rule 7: Use any resources you like. There are no rules on how you should learn.
Rule 8: iPhone is a memory constrained device where network and local storage access is slow. Parts of your application can be unloaded at any time, your application is responsible for maintaining it's memory footprint (not the user), and an event (phone call, memory, etc.) may require the app to respond accordingly and quickly.
Rule 9: It isn't about you. It isn't about your code. And it isn't about your code doing this or that. It's first about the user and responding to the user. It's second about your code responding to the framework. You don't usually tell the framework what to do. It asks you for things when it needs something. You sit and wait for it to talk to you. You're not in charge. You don't control the runloop; it controls you. You register to be told when things happen, and you indicate that you're the object who knows something about something (data for a table for instance). And then you let go, and let Cocoa do the rest. It's a very different world. I like it very much.
Rule 10: Relax.
When I'm coming to a new Xcode project, I open it up in OmniGraffle Pro. If the project is well organized, you'll see a nice diagram with a summary of the classes, the methods that are present and a little bit of how things relate to each other, important enums to know about, and other helpful information for getting a good overview of the project.
After that, pick a point like #mprivat said and run it in the debugger and get a feel for how things run. I like to set breakpoints with logs of the breakpoint name and hit count (and maybe the value of some variable or parameter if it seems relevant) and automatic continue after a little while to avoid pesky timing issues that can sometimes creep up when the debugger pauses execution. I use breakpoint logging so I don't have to worry about accidentally committing clutter code. (Be careful of pulling new code though because breakpoints don't move with your changing codebase. :))
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.
As a school project i have taken up making an angry birds clone in matlab. After working on it a little bit, i have realized that perhaps i bit more then i could chew.
Currently i am working on the physics of it, and while i understand the mechanics behind the game (collisions, inertia and whatnot) i don't know how i will implement it in the game. I am new to programming but i like it and have caught on to it fairly quickly.
In angry birds we are dealing with collisions between several OBB's and i have an algorithm for detecting collisions. I have a function that checks all the corners of every box and looks to see if it is within another box. I realize this is not the best way to do it but since i couldn't visualize the separating axis theorem, i chose not to use it.
When the collision happens, the box is penetrating into another box, when this happens i do a liner interpolation between its previous point and the current point. I do this to all colliding points in one instance (this is my method to resolve multiple collisions). Using the interpolation i detect the first collision that takes place and i implement a collision response.
My issue currently is that when there is one box sitting on top of another, this method doesnt work so well, because at every instance the top box penetrates into the bottom one very slightly, and i bounce it back. This causes my entire thing to stop, because i go back in time, solve the collision, and then in the next instance the collision is happening again.
My question is, how do i solve this problem of multiple boxes sitting on top of one another.
I have looked at all of the articles on physics by http://www.wildbunny.co.uk and tried to understand his method but while i understand what he does, i have no clue how he does it. I also do not know any action script so much of his code is gibberish to me.
I have looked through several other guides on the internet but none of them seem to make sense to me.
Here is what would be of great help to me, if someone could tell me what sort of method is commonly used to implement the graphics of a game like angry-birds, specifically the multiple collisions method (is mine good enough or do i need to do speculative contacts like wildbunny talks about in his blog), and the box resting on box problem.
Is this project difficult to do withing two weeks?
Yes, Implementing a robust multiple body physics engine in matlab, from scratch, without experience working on physics engines and without programming experience is too difficult for a two week project.
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.
Can someone please explain me what a software framework is? Why do we need a framework? What does a framework do to make programming easier?
I'm very late to answer it. But, I would like to share one example, which I only thought of today. If I told you to cut a piece of paper with dimensions 5m by 5m, then surely you would do that. But suppose I ask you to cut 1000 pieces of paper of the same dimensions. In this case, you won't do the measuring 1000 times; obviously, you would make a frame of 5m by 5m, and then with the help of it you would be able to cut 1000 pieces of paper in less time. So, what you did was make a framework which would do a specific type of task. Instead of performing the same type of task again and again for the same type of applications, you create a framework having all those facilities together in one nice packet, hence providing the abstraction for your application and more importantly many applications.
Technically, you don't need a framework. If you're making a really really simple site (think of the web back in 1992), you can just do it all with hard-coded HTML and some CSS.
And if you want to make a modern webapp, you don't actually need to use a framework for that, either.
You can instead choose to write all of the logic you need yourself, every time.
You can write your own data-persistence/storage layer, or - if you're too busy - just write custom SQL for every single database access.
You can write your own authentication and session handling layers.
And your own template rending logic.
And your own exception-handling logic.
And your own security functions.
And your own unit test framework to make sure it all works fine.
And your own... [goes on for quite a long time]
Then again, if you do use a framework, you'll be able to benefit from the good, usually peer-reviewed and very well tested work of dozens if not hundreds of other developers, who may well be better than you. You'll get to build what you want rapidly, without having to spend time building or worrying too much about the infrastructure items listed above.
You can get more done in less time, and know that the framework code you're using or extending is very likely to be done better than you doing it all yourself.
And the cost of this? Investing some time learning the framework. But - as virtually every web dev out there will attest - it's definitely worth the time spent learning to get massive (really, massive) benefits from using whatever framework you choose.
The summary at Wikipedia (Software Framework) (first google hit btw) explains it quite well:
A software framework, in computer programming, is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality. Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined Application programming interface (API), yet they contain some key distinguishing features that separate them from normal libraries.
Software frameworks have these distinguishing features that separate them from libraries or normal user applications:
inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework.[1]
default behavior - A framework has a default behavior. This default behavior must actually be some useful behavior and not a series of no-ops.
extensibility - A framework can be extended by the user usually by selective overriding or specialized by user code providing specific functionality.
non-modifiable framework code - The framework code, in general, is not allowed to be modified. Users can extend the framework, but not modify its code.
You may "need" it because it may provide you with a great shortcut when developing applications, since it contains lots of already written and tested functionality. The reason is quite similar to the reason we use software libraries.
A lot of good answers already, but let me see if I can give you another viewpoint.
Simplifying things by quite a bit, you can view a framework as an application that is complete except for the actual functionality. You plug in the functionality and PRESTO! you have an application.
Consider, say, a GUI framework. The framework contains everything you need to make an application. Indeed you can often trivially make a minimal application with very few lines of source that does absolutely nothing -- but it does give you window management, sub-window management, menus, button bars, etc. That's the framework side of things. By adding your application functionality and "plugging it in" to the right places in the framework you turn this empty app that does nothing more than window management, etc. into a real, full-blown application.
There are similar types of frameworks for web apps, for server-side apps, etc. In each case the framework provides the bulk of the tedious, repetitive code (hopefully) while you provide the actual problem domain functionality. (This is the ideal. In reality, of course, the success of the framework is highly variable.)
I stress again that this is the simplified view of what a framework is. I'm not using scary terms like "Inversion of Control" and the like although most frameworks have such scary concepts built-in. Since you're a beginner, I thought I'd spare you the jargon and go with an easy simile.
I'm not sure there's a clear-cut definition of "framework". Sometimes a large set of libraries is called a framework, but I think the typical use of the word is closer to the definition aioobe brought.
This very nice article sums up the difference between just a set of libraries and a framework:
A framework can be defined as a set of libraries that say “Don’t call us, we’ll call you.”
How does a framework help you? Because instead of writing something from scratch, you basically just extend a given, working application. You get a lot of productivity this way - sometimes the resulting application can be far more elaborate than you could have done on your own in the same time frame - but you usually trade in a lot of flexibility.
A simple explanation is: A framework is a scaffold that you can you build applications around.
A framework generally provides some base functionality which you can use and extend to make more complex applications from, there are frameworks for all sorts of things. Microsofts MVC framework is a good example of this. It provides everything you need to get off the ground building website using the MVC pattern, it handles web requests, routes and the like. All you have to do is implement "Controllers" and provide "Views" which are two constructs defined by the MVC framework. The MVC framework then handles calling your controllers and rendering your views.
Perhaps not the best wording but I hope it helps
at the lowest level, a framework is an environment, where you are given a set of tools to work with
this tools come in the form of libraries, configuration files, etc.
this so-called "environment" provides you with the basic setup (error reportings, log files, language settings, etc)...which can be modified,extended and built upon.
People actually do not need frameworks, it's just a matter of wanting to save time, and others just a matter of personal preferences.
People will justify that with a framework, you don't have to code from scratch. But those are just people confusing libraries with frameworks.
I'm not being biased here, I am actually using a framework right now.
In General, A frame Work is real or Conceptual structure of intended to serve as a support or Guide for the building some thing that expands the structure into something useful...
A framework provides functionalities/solution to the particular problem area.
Definition from wiki:
A software framework, in computer
programming, is an abstraction in
which common code providing generic
functionality can be selectively
overridden or specialized by user code
providing specific functionality.
Frameworks are a special case of
software libraries in that they are
reusable abstractions of code wrapped
in a well-defined Application
programming interface (API), yet they
contain some key distinguishing
features that separate them from
normal libraries.
A framework helps us about using the "already created", a metaphore can be like,
think that earth material is the programming language,
and for example "a camera" is the program, and you decided to create a notebook. You don't need to recreate the camera everytime, you just use the earth framework (for example to a technology store) take the camera and integrate it to your notebook.
A framework has some functions that you may need. you maybe need some sort of arrays that have inbuilt sorting mechanisms. Or maybe you need a window where you want to place some controls, all that you can find in a framework. it's a kind of WORK that spans a FRAME around your own work.
EDIT:
OK I m about to dig what you guys were trying to tell me ;) you perhaps havent noticed the information between the lines "WORK that spans a FRAME around ..."
before this is getting fallen deeper n deeper. I try to give a floor to it hoping you're gracfully:
a good explanation to the question "Difference between a Library and a Framework" I found here
http://ifacethoughts.net/2007/06/04/difference-between-a-library-and-a-framework/
Beyond definitions, which are sometimes understandable only if you already understand, an example helped me.
I think I got a glimmer of understanding when loooking at sorting a list in .Net; an example of a framework providing a functionality that's tailored by user code providing specific functionality. Take List.Sort(IComparer). The sort algorithm, which resides in the .Net framework in the Sort method, needs to do a series of compares; does object A come before or after object B? But Sort itself has no clue how to do the compare; only the type being sorted knows that. You couldn't write a comparison sort algorithm that can be reused by many users and anticipate all the various types you'd be called upon to sort. You've got to leave that bit of work up to the user itself. So here, sort, aka the framework, calls back to a method in the user code, the type being sorted so it can do the compare. (Or a delegate can be used; same point.)
Did I get this right?
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 13 years ago.
Out in the dev lang there are many many, frameworks for all types of languages. For instance, javascript has jQuery, which I use all the time without even thinking about it. Then for php there is Zend and CodeIgnitor, Ruby has rails, Python has django. That's just a few off the top of my head.
I have always been the type of person that was against a framework, especially for PHP. I was always under the impression that using a framework would make people conceive you as lazy developer or to have the inability to code in the raw format. However, for a while now I notice large projects are being made in these frameworks.
I am very curious as to what the opinions are of everyone. Does using a framework make you less of a developer then using raw code, also lets add in a variable and say that you don't already know all the ends and outs of the primary language?
I always lived by the idea that it's better to write everything yourself...
... just to see how it works, then throw it away and use stable frameworks :)
While this may sound like a joke, there's much truth here -- rolling up something yourself will teach you a lot. And what you learn will allow you to better utilize what is already available.
See Not Invented Here.
Using the right framework gives you the ability to get actual, real work done. This means, IMO, you're more of a programmer, not less.
A good framework is indispensable in Javascript, to tide you over all kinds of incompatibilities between browsers that would otherwise drive you crazy. In languages where you have more control over the runtime environment, it's not indispensable, but it can supply you with a lot of useful functionality and stop you from reinventing the wheel -- so using the right framework for the task (which may not necessarily be the most popular one, if what you're doing is a better match for a different framework, perhaps a lighter-weight or somewhat specialized one) doesn't make you a lesser programmer, it makes you an intelligent one;-).
Understanding what's going on at (at least) just below the layer of abstraction you're coding to is an excellent idea (partly due to Joel's "law of leaky abstractions"), but that's no reason not to use a lower level of abstraction than available and suitable, except in a "learning and experimenting way" (i.e. not in production work;-).
Not using one makes you sure hell of a lot less productive however!
The only way to use 'raw code' is to write your programs in 0s and 1s. Otherwise, you are using a 'framework' of some sort. C is a layer on top of assembly which is a layer on top of machine code. That doesn't make a C programmer any less or a programmer - she is just working at a different level. In the same way, using a framework on top of PHP means you are just working at a different level. There are good programmer who build Zend (and other frameworks), and there are good programmers who use those frameworks to build business applications. Being an application level programmer is nothing to be ashamed of - it is hard work to do it right, whether or not you use a framework.
Davidmoreen, does using ASCII make you less of a programmer? I say, go ahead and make your life easier.
alt text http://prontiso.com/images/hardcore_keyboard.jpg
No more than using a language instead of raw binary does.
As the complexity of the tasks we are trying to accomplish increase, our only choice is to build on the foundations that others create. The main goal of any programmer should be to solve a business problem in a cost effective manner. If you don't solve real problems in a cost effective way then you definately less of a programmer.
I beleive it's important to understand the fundamentals of your tools and know how they work. THere'll be times when you need to work on the framework itself or just understand and debug what it's doing.
That said do you really need to remember to call session_start() at the beginning of every page load, or include the config files, or establish a database connection, or any one of the other minuetae that a framework will do for you and leave you to get on with creating the "unique" portions of your application?
I disagree with learining and using a framework without understanding the undelying language and concepts, but choosing to use one gives your code structure and makes you a lot more productive.
Being entirely dependent upon a framework makes you less of a developer. Using one as part of your toolkit when the need is there does not.
There is zealotry on both sides of the argument. You have the ones so starry-eyed about one particular framework that they use it for /everything/ (I usually see them in the form of beginner Railers or PHP programmers). Then you have the ones that are "hardcore" and as such "don't need hand holding", which more or less translates to them using last generation's frameworks instead (beacuse, after all, it's turtles all the way down).
It really comes down to knowing your framework. I would posit that using a framework without knowing its strong and weak points does indeed make you less of a programmer (if you are the one in charge of the decision), and should be counted as a cardinal sin. Study the frameworks, study the problem domain, make the informed choice, not the biased one.
Being able to make these kinds of decisions is what seperates good programmers from the... not-so-good ones.