WWDC2000 Session 415
Transcript
Kind: captions Language: en good morning everybody I hope you we understand me even with my French accent I'm going to try to talk slowly so everybody can understand especially the Japanese people in the books they told me to choose peace talk slowly otherwise we don't understand anything um I want to talk about advanced cos so what is advanced EOF something like a month ago somebody came into Maya into my office and say hey you're going to have a talk ewww you're going to talk about advanced cos I can say okay what am I going to talk about I say oh it's your problem you know that's adds on to us you know you're the advanced wave guide deal with it so I took a piece of paper and started you know jotting notes on it and say okay and what can I talk about I can talk about how how to write an adapter or I can talk about how does some stupid things that see some customer doing I can talk about all the features in us you know we have plenty of features and and I want to see the other member of the team and ask you know what can I talk about and everybody had a different idea about what I should talk about and I didn't end up with this list I could have filled the 18 sessions just with just the content of the list so it was really hard to find something that advanced and something that's interesting and I finally try to reduce the thing in a session that lasts just an hour I'd have trying to reduce it and reduce it and then real cessation and it was C 2 hours so I reduce it a little more and I did not always imagine that I contain only two items but these are good items first I came is what I want to cover is how do you do a good entreprise object you know what's what what's the process what should be the mindset in a diversity respect on the way it's exactly a really odd problem when you see all the demos of director Java client director web or any any kind of world objects demo you know you see the demo is always starting oh I have this model if I have someone like this you know just drop it there but actually making the model file and getting to this way I can just drop some models by in your application and having everything work is that we quite tough so I want to talk to talk about this going to take half of my time and the second thing I want to talk about is about a new featuring features in four five we introduced a lot of really cool thing in four five and who in the room is using four five that's that's okay so I want to point out what are the little things that we did and the big thing that we did in for file we're not in for that we're not here before and that you can use in your applications and some of them are pretty good so let's start how to design a good deal where do you stop well you start with your data model you start with your data you start with what's in your data base most of the time you have an existing database that you have to deal with some of the time you you have the Liberty to create your own database and that's better because you can make better decision to integrate with the US but you know we know we life is and you have to integrate with what's already there what exists you know and deal with this data baton is right always know we're going to changes you and giving you nice access to it stable so when you look at at swept in your database and and you're thinking about integrating with UF the first first thing is think about the performance implications of the design if if you have you know if your customer table as every role as the 10 megabyte blob in it well you're not going to have good performance because you're going to fetch these blobs over and over and over again is going to take all your time also when you look at the database especially you data arrays that's you know really split in little tables all over the place and you have a tendency to think oh I can model that with object Meriton that would be great you know I can license 20 layer or finger items thing and it's going to be great but the problem is there is a preference problem with inheritance inheritance is working but it's it's a dangerous thing if if you go with with something that's too deep you're going to have really really keeping the performance up and having being able to fetch all these things not mentioning that you're going to some time you're going to have some problems with with us in certain case of inheritance that you are going to need to deal with it if you don't have any inheritance that's way more way simpler to work with with the US another thing a trigger installed for seizures u.s. is working fine with trigger and for install procedures but you have some work to do in order to make this thing work by default we don't do anything for in this area the work the worst I've seen was actually an internal project that effort where we say we see this internal application and we decided to try to write a prototype to replace the existing application using US and Java client actually and so we asked the DBA prosody now isn't he in charge of database a give us database access right and this person gave us an access to a database that was really weird it give us an access to a bunch of views views on every single database no no really table just views read-only views all over the place and to modify the database was oh we have already stored procedures that you can call and doing all the things and what we did like we were encoding out their business logic in the stored procedure aware of the evaluation rules and everything from the database standpoint that makes some sense you know from the DBA position it doesn't want is database to be touched you know in a way it doesn't understand it but for a new X point of view the nightmare you know just is just insane you cannot just you have to modify audio updates you have to believe I already did it you have to modify or your fetch because of course or the view was giving us we're doing joint in the back so they were actively slow in order to get data we had to to fetch for multiple views and doing join between the views and getting the same data multiple times this is just just insane and to be right with you we gather we decided that it was not worth the trouble and we banged on the GDA and until he gave us real access to the database to the real tables and at that time we discovered why there was views is because the real database was you know no database it was revised and revise and revise and rewrite and it was just a mess and it took us something like a week just to understand what was in the database and finally less thing you have to think about is how you are out your primary key are generated in Kenya in the database that's something that that's important and we kind of defer this thing oh I'll deal with it you know later and you have to sing it right away because it's going to impact the design it's going to to change the way you're going to interact with the database I have a slide on primary key generation here showing us the four main way that u.s. supports generating primary key primary keys the first is just ways you control the database you're the only user of the database or you're creating the database let the you adapt or under it just you know if you have no records as a sequence if you have Sybase and stored procedures using Tatom ODBC that's you know just a separate table that we read and update and do this kind of things it's working just fine but you have to be aware that actually is the slowest where you can do primary key every time you insert an object you're going to do a round trip an additional round trip to the database to get the primary key for this object so if you answer you know 200 objects that's 201 trips so if you don't insert a lot of objects that's that's fine if you insert a lot of objects you may want to try one of the other approach the second approach is in your database you make the primary key of your object and its data or some kind of blobs are you on the application side you make this an NS data and you make it exactly 12 bytes long what's going to happen there is webber's x UF is going to generate this primary key for you just you know creating something from the process ID the IP address then a timestamp and some of the stuff we generate something unique on the application side and stuff that in the snapshot and send and send that to the database server so we don't make any round-trip so it's way faster you know it is my stump here where is X 5 for Java why is it there well you know we're going to your Java in future we don't have a process ID right and we have no way to get one so we had to change this city really and I just want to point out that for the next we the Weber objects the 12 by binary is going to be a 24 by binary so if you're using this feature you have to be aware of that because that means that you your database is going to need to change when you're going to transition from 4 5 to 5 for Java that's why I use this little red warning there third way of generating primary keys is to use the delegate database context new primary key and you basically do whatever you want in there you just return a dictionary containing your primary keys and at the end of it this is you can for example do that to widow actor you can you can use sequences the same way that we do but instead of asking you know one number at a time you can just go there and ask for hundred numbers and and then reuse them in memory and when you are out of then you ask for the next batch of 100 that's a way to to solve the performance issue with the first one and finally a way that actually that's actually already simple you make the primary key a class for party attribute so it's part of your object and in a way coming session you just stop something in there and that's your primary key simplest way to do it so once you have your data model you understand what's going to be in your database how you're going to generate two primary key how you're going to make you have interface with your stored procedure how well you're going to deal with the triggers all this kind of information where it's time to build your modified to model it is mapping between your database and your objects the first thing is spend time on your modifier your modified is very important that's what you advocate that's what the UF is going to rely on to mess with your objects so if there is something wrong in the model file that we are going to mess something wrong with your objects so make sure you click on all the inspector or you look all around you understand all the checkboxes read the documentation I've see I've seen I've seen a bug from the customer one seeing existing is not working at all and I was going to help reduce it and impossible produces a finally I ask you design your modifier and your database I need this huge thing in a mail attachment and I looked at it and looked in the model file and there was your digital textbooks like propagate primary key that was checked on one of the Russian ships and of course nothing was working because he was trying to propagate from our key something that should not propagate just bad so you know I told him you know just take some other file check out this thing it's working just fine and why did you check this thing say oh I don't know I just wanted to know what you think I didn't know what the thing was doing so just you know checked it and so this is every single check box in this little panel is really important you should check propagate from RIT you better know what this thing is doing because otherwise you're going to get in trouble a good way to see if your rights on ship are good is where to spend some time in the model file is a stupid model file we have we have in our example to studio movie and the one you see in all the demos the reason where you see them in all the demo is because they are actually good modified you drop that them in any demo and your demo is going to work because modified is well constructed so what you can do is compare your relationships if you have to many many to many relationships go looking you know in the movie database the relationship between movie and and talent for the directors of a movie and and see if the checkbox are the same way if the checkbox are not the same way as you also have something slightly different try to understand why just just go look at all these relationships everywhere in the in the examples I think we have all the possible relationship define in our model file we have too many web to one with one propagate primary keys we have you know optional to one monetary to one I think we have we have almost everything and last but not least you know do the demo you know the director Java client the mood Andres did just take your mother to take the topic to Tom played for directed directly interruption within their compiler thing run the thing you know and if the application to get back looks good there is a really good chance that your model is good if the application you get back is showing some Maltese on some kind of relationships you don't expect there you know the query window contain all you wanted is there is probably something wrong in the relationship because the way directories of a client work is it's analyzing your model and making guesses on what's good and not good based on the different relationships and how you specify the relationships if the optionals are not optional etc so that's a good way of validating your model side and finally once you have you know you have the database that's all set up you have a model fight to work with it it's time to implement your logic and I'm promoting you allergic you have multiple choices the first one is between your generic record just the data you don't need anything else on the data so that's why that's what that's walking in all cases second case is you want you can use custom entreprise objects where you can actually build some logic in there and frame up mittens but when you suppress custom object and in Java and put your instance variable here you are every time you change your model file or you change your database that's change your model file and then you want to change your entreprise object it's going to you're going to have to do some maintenance because you're going to have to add and remove all these instance variable and access or and stuff so in four five I already talked about that yesterday I think you can subclass your generic way code gives you lace maintenance because you don't have to maintain of this instance variable and it gives you better performance in Java because you don't have to cross the bridge with all your attributes all the time so that's that's an example of who yo generic record class I like it's a personal preference I like to have no public final string with the name so I can just key that you're coding with no names and this is the way you want among two accesses yujeong at first and promote your access source by the way web objects any of' when they access your ears don't need the access or so you don't have to implement all the list of access or you know if if you have 30 attributes in your objects you don't need to implement you know 60 methods and and 30 is final strings you can just remove everything unless you need it in your business logic to access it keep losing a smaller if you don't put everything in there so huge any quicker you can see here this stored value for key and take stored value for key singing I want to talk a little more about this because when when you F and web objects using accessing your object to put value into it or to get value out of your object we are using key value coding and it's really important when you did when you write your you to understand how key value coding is working and this is actually this is going to reflect its meaning to take away yes we have two ways of accessing your objects we either use Kiba recording or we use stone t-value cutting and for both of this way to access your object we have get method and set method and different way of finding all this information so let's start with the simplest way Kiva recording you know your web objects application you have a binding in your UI that's bound to your display group and your object name web objects you're going to use Kiva recording to get to your object and what's going to use well it's going to look in your objects and see okay what do we have in there is their method name if there is no method name is going to look for an instance variable name name if it's if there still nothing is going to try for under bar named as method another name as an instance variable fairly easy by the way this search is done only once you know I want the class we do the search and we cache information and then we have this this is saying that you know you don't want to know okay so this is path even if it seems that doing a search or search or search searches it is plenty food fast the second method is doing exactly the same thing it's looking for set method saying set name it's doing is looking for an instant variable name is looking for another set name and another name same kind of search now Kiba decoding is used by web objects exclude objects is using only key value cutting is never using stored key video coding because web objects is a user of your eel it's just getting information from your yield displaying it in the UI and when the user change something is putting back something in your al stored key value coding is another Beach stop your recording is coming from the other side of your eel this is something we use when we fetch data from the database and put it in your eel so this third key value coding is used exclusively by EOF it's mostly used when we snap shot it's used when we fetch its use when there is anything that anything led us to do with the persistence of the object we use stored Kaveri coding instead of using key value cutting so what are the difference between the two what the difference are easy that's just the order of the search we look for the underbar before looking for the real thing and the same thing for the set method so what does this give you imagine in your object you have an instance variable name and overall name and you have a method name and the method set name so when you're going to fetch your data from the database we're going to go straight to your instance variable it's under the name that's the first one I'm going to find we're going to go straight to this instance variable stuff to design it and that's it now when and when you save the object we are going to go straight to the instance variable again get the data there and save it to the database now that's different in key value coding because you have this method name and this method set name so that mean that when when what object mean to access your your object or when any user is going to access your object it's it's going to to execute some some of your code so you can actually do something else in this code because it's not going to impact the fetch the fetch performance because the fetch grammars going to access the end of the name first it's not going to go through your method but so in your method you can you can a unsub in your business logic by putting some some kind of behavior when you do the same name you can imagine in set name changing a timestamp on your object to set the lettuce you know time that your object was change or anything like that so we can use this in your business logic and this is something that most people are not aware of you can by being careful you can do some things that are that are in your in your accesses that are executed only when a user is changing something not when we are when us is fetching of course we can change the behavior you can say oh you know I don't want I don't want you to access my field directly and oh I don't want to use stored access although justjust always use key when you're coding and never use doorkeeper decoding and the new F is going to behave the same way than label Jax's little word of warning again we'll use X type of java key value coding is the way we do it is we use your blue key C runtime the way we do it in four five is we use the objective-c runtime even if you're in Java we use the objective-c runtime that means that if you have a you know private string name who cares about the private right the objective-c one time we just touch the data in your private value but no problem well we've done queue Java and pure Java the sling interesting is they have this security thing and when you have a private thing it's really private can't access it so an same thing for protected if you are in a separate package and and your your instance variable is protected where we won't be able to access it with key value coding or stored key value coding or whatever so look look at your yields actually look at your components - if you have anything that's private or protected maybe keys are occurring won't be able to access it when you converge to move objects I for Java it's probably going to be covered by your is not somewhere because it's going to be an interesting problem we have some solutions you can put everything for private there is no solution for private is private we can't access it for prorated we have some solution that we can you know run some loops around and do something there but be aware of that value date variation student promoting geologic validation validates name or validate you know first name validate whatever valid salary just something on this method on your object is going to be called automatically when a web object is changing you every time it's going to be call automatically if web object is changing our display group is changing in all of the cases it's not going to be a very you see this 12 X 5 for Java you notice that my validate name is taking an object not a string actually I think the let us build now we can put a string in there so I should have removed this sticker because we actually fixed it so you can put string or you can put objects and we're going to find the method the method way that will say if I edit or delete by delayed for in sir by default before you of them do exactly the same thing they go to the modifier basically and shake you know everything you check on the model file if it's mandatory not mandatory whatever and it's also calling all this validate methods plated name and whatever you can override these methods on your you if you override them called super because we don't go super all the validation that you modify is never going to happen and don't update your objects while you're doing a validation your validating something that somebody's passing you you are not changing your object at that time changing your object is done in set name and it's pre method very dead four-digit value did for insert I call at the end of the request response loop and various for save is of course code every time you press Save button in your editing context automated you can implement on your yield unable to set null for key if in your database you have some kind of number or flow whatever and in your ear you have float or a double or something that you cannot put knurl in it this method is going to be code on the audio if this method doesn't exist we are going to for an exception and in this method you can do the behavior you want you can you know use another variable to note that this exact winner interesting method also away from insertion is called every time you insert an object into anything in context we could work insertion it's a good place to do all the initialization for your object and finally awake from fetch that's what we get your object from the database we fetch it you put it into your editing context we call away from fetch when we're done with it you can use this away from fetch method to set up for example the right value if you have you know customer object is the first name and last name and you want a full name access so in a way from fetch you know you can read this full name actually this is a bad example I won't recommend that good like we do that lazy with the full name the first time somebody's asking for it but there is some interesting thing you can do in their method you should not overwrite on the other hand I probably will change and we'll read will read is useful faulting and will change is use to detect that you are maybe going to change the subject maybe let's not guaranteed when will change is called maybe the object is not going to change after all so if you use will change say obscene use of will change saying okay I'm going to override will change and every time a receiver will change I'm going to change the timestamp on my object is my object you going to change so I want to light this time stop this is actually not the right place to do it because it's it's cold sometimes when there is no changes at all I choose a good it was faster I'm going to run out of time their ration tip management's the only only one method you should know about is that object both citation ship is key if you use anything else you might run into trouble because if you model change and you don't change your logic you may get some kind of an constituency this method is the only one that's taking care of everything if you use this method everywhere you're safe you have the ration ship you don't have relationships the class properties not the class property is going to work in all cases so it's a long method to tag but you are known you have you have completion in project builder so that's you know easy you press f2 and windows and escape on my question servants just filling the blank so please use this one and I don't have time time to go into that GPO is clean don't put you access specific code in there don't put weather object specific code in there because if you do that one day you're going to regret it if you have your use on your you on the server using web objects and you put some waiver Jake specific code that you tie this thing with your component and whatever and then you know a month later you have your manager coming and say hey you know we need the Java client look cooler so that wEDC I want this thing in Java client tomorrow all right and if you have good objects code in there you won't be able to do it because you know in Java client on the client side there is no web object you just have UF right and you don't have you access either you have your distribution so keep these things separate everything you need for new is inside here control the only one exception that I can agree on is the utilities each reason is actually in EU access and it's bringing things that I'll use pretty that things common things back back to your ear so you can they don't really use utilities we have any utility in Java client to that's working different it is working with your distribution to the working with with you access so that's it for the first part of our presentation you know how I see you should do a good you start from from the bottom start from from the data and video your model spend time on your model really important spend time and you invalidate Ramudu you model make sure that that is correct don't let your junior programmer go in there and click on those check boxes because you want to see what the thing is working and and the last thing you do is implement you allergic you can of course cycle this thing okay it's not a rigid thing you have to do it you know Erev so a wreck on stage it told me to do this this and this no you can you can cycle you to just just be careful when you cycle to keep everything in sync and keeps the thing in sync for all the way from the top to the bottom there were some eight on its ways of doing this if you are starting fresh and writing an application and you have control over everything you can start from the model file and then generate the database but personally as you prefer to start with with the database but that's probably a personal preferences portions at this point so let's move on to the new features in four five the thing that might cause you trouble or might actually save you but in some cases first one or we talk about subclass you generic code and we're going to spend more time on it as giving you performance this year if you are in four five using Java and giving it's more flexible than then customer objects slash maintenance and and and us for it you know raise your hands once the one we asked for supplies subclass abiogenic record that's that what did you bother ok actually I think I think maybe there was only one person but he was really vocal them important feature in four five shared it in context this is your regular web object application with to lead in context to object graphs as actually sitting in context and what shared editing context introduced is a way to have another editing context that in the middle and that contain some objects that are shared by all the other editing contexts in your application so this shared it in contact in the middle is read-only because if you share that out you cannot change that I you know remember that every editing context on both side may be running a different thread and this kind of things so this data in the middle is read-only no way to change it these objects in the middle also our only destination of ration ships because you know the Chevrolet ships going outside of the Sheraton context to another editing context you know and imagine that you have something the relationship going from this blue object there to the proper leading context now you're in the read it in context and you follow the ration ship now I'm going to do blue object to the blue object and then I'm following this also relationship and you do end up having an object graph that's spawning multiple EDD contexts and that's bad you don't want to do that ever never never don't do that if you do it you're going to every big trouble and we had crashes and everything so keep the so that the ideas unique in scope change in a formula - OH - to us - OH - web objects for 4.01 the unique in scope was an editing context that was the end of the story now the unique in scope changes the editing context plus its eventual share the dinning context the two together is your unique in scope you have to be aware of it in some cases but unless you but really if you're doing some weird things usually it's fairly transparent to put your objects into the share it in context there is a checkbox in your muddler you can check to say oh this thing is shared and that's it and now no matter where you fetch it when you fetch it into going to be in shared context and that's going to be shared between all the all the use of the editing context in your application everywhere it's good for read-only data is good for example if you have a catalogue app you can put all your products in the end you know rivers browsing your catalog application is reusing the same objects over and over again third interesting feature snapchat with Counting talked we talked about it yesterday also you fetch an object needing context we create a snapshot down there right now you fetch an object in an other editing context we now rest count this snapshot and when the two objects are gone from memory the snapshot is going to it's just really simple that's that's a feature you always thought was already in you if right so now it is as if you reduce memory footprint if your snapshot freshness because you know if nobody is using any memory it's gone so next time you need it you are going to refresh it so it's going to be fresher a couple of good shells with this feature that are actually interesting if you used to use global ID if this actually this gocha's this one apply only to Objective C if you used to use your global ID all the way around and passing global ID to move an object from one eating context to another you know look at your code make sure you retain it because now global IDs are going away before they were never going away but now they are and I'm pointing this thing because actually we add the problem in our example framework in the movie example if you give the 401 and the four fives are going to see the bug so be careful with that and if your application assume that because you fetch an object once you have the snapshot down there that's not true anymore I don't think you should make assumption like that anywhere but if you do be careful when you move to four five next feature is actually the others to explain the simple concept it's difficult to explain so the middle arrow up there at the top is a timeline going from the past to the future and I'm let's say I'm creating an editing context so in my timeline I have this properly reading context there now I fetch an object into this editing context at the time of the fetch we you access is putting a time stamp on this snapshot saying hey every seed is the snapshot from the database at that time you know and market remember it now you click a second editing context and such an object into it so every editing context as the lag time when we mean by like time when the time of the creation of the leading context - is like time give us an absolute date and this is from this absolute day we determine if we can use a snapshot or not it's a snapshot we have in memory is after this absolute date we are going to use it it's a snapshot we have in memory is before we just are going to try this natural and fetch it fetch it with the object again so here you can see that when after this fetch I snapshots at that time on the timeline and then I created the second editing context and the date such give me the absolute time is the date of the creation of the leading context and in that case we see that this object there is fine it's in my time lag so I'm going to reuse a snapshot now if I create a third editing context here you see the timeline again and then the lag time and you see that the object is not in the lag in the lag time so in that case in the third it in context is I expect the object I'm going to actually respect from the database updated snapshot and of course send the notification thing of objection of objects change in store and data object everywhere is a snapshot change and we put a new time stamp on this object on this snapshot so next time and nobody can rotate things you need it it's going to be there so what does that mean that means that every time you create a new it in context have the potential to research some objects from the database because you're editing context was created later so you can control the freshness of the data the shorter of the lag time you use between your photo editing context the shorter life span your snapshots are going to have that mean that if you don't use the objects if you don't fetch these objects really often you are not going to update and generate all these freshness update all over the castle place it means that we are going to fetch from the database only if you need it and we are going to refresh only if only if you know we know that when you're really enjoy editing context knows it and it is also an easy way to get updated data you want to update a certain graph of objects in your application where that's really easy you create a leading context you said is fetch timestamp to now so you remove all the lag so you're creating ignore Tex you remove all the lag decide which everything now and you fetch the object graph you want to fetch all right that's going to mean that you're going to update the snapshots at the bottom for every single object that you're fetching this new leading context and at the same time refresh things in all your in all your other leading contexts so you can you can use this instead of fetch refreshes fetch specification with the refreshing objects and all that that's actually another way to perform the same task that I think is exactly little cleaner but it's possible only with four five still following nobody's sleeping it fine different 14 another four five feature this is so a three four five education we're switching you know you're fetching a bunch of objects and what does I find when you fetch an object you know you fetch the object and then for every relationship around the subject we're creating a full now either or two unfolding like I have in my little graphic they're all too many fold so that means that's all if if you're on TT as something like you know ten relationships and you fetch fifty objects where you are going to create this 50 object and you're going to create another 500 objects around them right so fetch performance it impacted by these kind of things it's usually fine but we have to add the performance it's actually a really good feature of course it's a trade-off you know if we don't do that that means that we don't have a transparency of do you just following a pointer and get information that at the end of water and having the fault firing for you you will have to do accurate something so what's different 14 different 14 says when you fetch an object and there is ten relationships we are going to create one object per relationship no more so if you fetch if I retake my example again yeah ten relationships and you fetch 50 objects you're going to create your 50 objects but you only are going to create ten objects for your ration ships and we're going to make every single deal that you fetch point to these shared objects because in shared object different food these objects actually note folds just a way to get a fault later and all of that work is when you need to definition of the relationship before following the pointer you different fool give me my rifle give me the thing I should have got when I fetch and we have a numerator to do that this name will read relationship and you pass yourself as an argument and you send that to the default food and you get the read food this feature is optional you don't have to mathematic it's giving you big advantages advantages it's giving you faster fetches and it's less memory usage because you don't create all these objects over the place and the only method you should know to work with this with is we'd-we'd relationship when I say it's optional it's actually optional unless you use a generic record if you so class you generic record you generic record is using default holding all over the place but it's completely transparent for you because you don't have instance variable you just access the dictionary just odd key value coding and starts evaluating on Yeojin Erica knows how to do these things so it's completely transparent for you another interesting side effect of this feature is inheritance remember inheritance when you pointing when you're in Objective C and you have a relationship to the top of inheritance tree there when we fetch your object we create your relationship but we don't know what kind of objects going to be at the end of relationship it could be you know the top of any returns 3 or anything below any kind of objects so the way we do that in objective-c is saying a you know we don't know which object is going to be so we are going to create we're going to look at the tiaki and create the largest object the largest piece of memory that could fit one of these objects and allocate the thing there and then when we file the fold we are going to play some tricks with with the objective-c runtime changing yeah is a pointer to point to the right class and doing some some insane things in their default folding actually get rid of all of that because default for thing you have a different food you don't have the real object so that means when you throwing the food what we do is there is any inheritance involved we are going to go fetch from the database the information and get the role before creating the object so we know what objects we need we need to create and the tricks the trick we are playing in Objective C is actually not walking at all in Java in Java you just say object new object and that's the end of it there's no way to turn the either pointer and do all these neat magic that we used to do so the only way in pure Java that inheritance is going to work this way yeah different folding so another 4/5 feature database reconnection info five if you lose your connection to the database we're going to try to reconnect automatically number of us call is saying you can change the behavior we have two delegates that you can use you can if there is if we try if we lose the connection to database before we try to work on like we ask you some questions in age who I try to reconnect the same database to another database or do you want to under the reconnection by yourself one thing we need to know is all these things assume that you're connecting to the same database that mean that we are not throwing away any snapshots so if you're connecting to a different database it's your responsibility to make sure that your snapshots match what are in the database so you don't have optimistic locking failure when you shouldn't have one we change the behavior of missing codes coming coming back to how do you create all you create an object you know you fetch an object and you have a fault to this it's only four to one you have your relationship to a two to another object and this object when you fetch you have a foreign key for you know so you are going to create we can create a global ready create this thing and say okay we need the subject later here it is and then you touch it subjects you go to the surveys and the subjects not their groups what happening for and before was we just give up and say oh you don't have to subject them database your database it is consistent too bad let's for an exception problem with this exception it was thrown all over the place you don't know where to cache it could be while false following something your business logic could be worth following a dot notation inside inside with objects to some kind of bindings it was actually thrown all over the place it was really really hard to catch so in four or five we are not sending an exception when we discover these problems we are just knowing that there is a problem and we send you an MC an empty object the exception is going to be thrown safe if you try to save and don't do anything about this object you're going to get an exception to yet you're trying to save something but your database was inconsistent in the first place to deal with it and you can at this point insert this new object and do everything you can use the delegate to control the behavior where you put a nicer delegate this is the only one delegate you need to know for this is database context fail to fetch object if you want to produce behavior you can just for an exception in there and that's it you have the previous behavior or in this method you can actually deal with the problem and say oh yeah I'm missing the subject let me go insert it into the database we fetch it and do all that and it's going to be fine for five feature another one that's good this one I love it a new editor you adapt your context your database context you can collimator that set default delegate oh it's a class later you call this once and be done with it you don't have to go fishing tracking or the exit or also notification a I have created a new channel a wedgie let me do these delegate of this thing just one place and you're the delegate over everything yeah I don't know what we didn't do that before just probably two hours I'm kind of this thing everywhere and just it's a lifesaver wait another four five feature a Depp adapter a lot of requests for a lab adapter yeah we want to access at that we want to validate or user we want to you know to have all these things so now we have an elaborate or interesting the LDAP adapter can you know read the date delete it's an adapter it's working like any other you adapt or in UF the interesting thing is you don't need a model file to do authentication don't need to build a big model file to do that authentication is actually a really simple protocol so the LF adapter has a static method that authenticates user and you pass its username the password and the information about you know total depth thing is there what subtree what you know and this thing is returning is retaining what is the thing we're joining probably returning a boolean yes/no easy choice it was can you is this user of legitimate honor so this thing interesting is this is interesting figure because it's really lightweight and you don't need a new model for it and that's the most common use of the LDAP adapter so here we go list of sort of five features I went over I don't think it's completely missing a couple but these are the most important ones in UF that I want I want to before we finish the thing I want to stress one thing that I've seen done over and over and over again and I'd like I'd like to - I don't know which reference you're not doing these things again is a thing a lot of our customers trying to force with UF to work in the way they think us should work right and it's you know you think oh you it should work this way so we know is know EF is walking this way so I'm writing my code thinking that e what is working this way and then I come to the concrete after a while I say hey this is not walking like this at all Jesus he was walking this other way and instead of instead of trying to fit with the UF what you're trying to do is you know coerce us into coming there and work the way I want it to work dammit you know and after that you know the pod of month later will receive I'd sit in my office I receive an email from super or telling me you know I have this Wilberg and I don't understand it so I look at the dog comfortable you see done anything and and and then the judge send me an example well you know it's the world customer application is 20 mega stuf and you end up buying trying to find reproduce this thing and you don't end up finding that it's because try it you try to coerce its into working the way you think it should work and and not try to use it the way it work and you by doing that you know you're going to introduce bugs it's going to be impossible for for us to fix them because it's actually in your code right so message work with the u.s. not against it just try to understand how he wife is working and try to play with us the reserves there is a lot of room to play with us if we have delegates everywhere we have a lot of ropes that you can hang yourself with you don't need to do your stuff to one yourself we can just usually where the weight was intended to be and you can you know it should eat yourself with it so take that as a message please try to work with it try to understand our us is working us is repour foot there with a lot of features in it if you think there is something that the u.s. is not doing well talk to somebody else maybe is going to tell you a different view that we there is always ten ways of doing something and there is ten ways there is three that are you know going to work well with the US and there is seven that I'm not going to work well with you have try to use the three that are going to work with the US and that's it you