last day (15 days later) » 

6:19 AM
Holla
 
Ben
Hey
 
So
Let's start with a Plugin. Just because it's easier to understand.
 
Ben
Miniman also did link me to this tut, which I have been working though (though I have only created the classes, and not much else)
 
Plugin is just a ready to execute code. That's it. For some environments it could be compiled code and your plugins will be DLLs, for others it could be even just a source file.
The purpose of plugins is functional extension. So, your program don't know how to do many things. And with plugins we can add load up some new functionality.
Of course it depends on what kind of program we work with and what API for plugins allows.
Example of plugins: filters/tools for drawing apps: Paint.Net, PS and so on. Easiest that came to my mind.
 
Ben
Ok. Following so far.
 
6:23 AM
Ok. Now the hard part: Interfaces.
 
Ben
Just to warn you, I may ask you some really dumb/obvious questions through this, and this is because I don't know, and I want/need to know
 
That's ok and that's good.
If you don't ask dumb questions then you hide something ;)
 
@RollingFeles Are you a Felpurr Ninja? I've been wondering.
 
Ben
APIs are basically just a door for your plugin to get in through; or, more accurately - a door that your program can access the plugin. Yes?
 
@Miniman No, I'm not. Who/what is Felpurr Ninja? :)
@Ben Simply yes. Not so accurate though.
 
Ben
6:26 AM
(I also like to try and explain things with analogies. It helps me relate to something that I do understand)
 
API is a protocol. Imagine bureaucracy. Two organizations.
 
Ben
Ok...
 
They're rigid and can only communicate following something written in a very serious document that explains how they should communicate.
What you can send one way and expect in return.
So, in the end API is a definition of the ways for communication.
In more simple and practical sense
 
Ben
@RollingFeles Yep. Gotcha. The program sends out information, and expects something back.
 
Yeah. And it should know what to send and where.
 
Ben
6:29 AM
The API is the means to do so
 
I wouldn't call it a mean. API is just a name for it. Beneath there is a lot of different work.
Do you know what a function/procedure/method signature is?
 
Ben
@RollingFeles Uhh... I think so? public string s()
Or... actually a better example: public void Method1 (string s, int i)
 
public string s() {
return "Uhh..I think so?";
}
 
@Ben yeah, you're right.
Modificators + return type + Name + arguments.
So, in the end
Any interface is just a bunch of signatures.
public signatures *
C# adds properties to this list
But properties has high level semantics. Low level - it's just another methods.
 
Ben
@RollingFeles Right. I've seen that, but I've never really understood why - primarily because I didn't understand the purpose of an interface - it just looked like an empty class with method sigantures in it.
 
6:36 AM
@Ben nay-nay.
C# interface key word
for an empty class.
I'm speaking right now about interface in a general sense.
 
Ben
@RollingFeles Right. Ok.
 
C# just use this keyword to free us from writing abstract classes full of abstract methods with only public accessors.
 
Ben
Been there :/
 
So, the interface(high-abstract level definition) is a contract.
 
Ben
Ok.
 
6:40 AM
I, the class who implements interface IYetAnotherInterface, vow to implement everything that is declared in this interface and made it part of mine interface.
Something like that :P
So, in other words, if a class implements some interface(in general sense, but in C# that would be those types that declared as interface)
it just tells everyone that it ready to serve any call that declared in this interface
actually, not the class, but it's objects.
so, API is more general in that sense and it's still a contract.
When we say Plugin API we can mean two things:
API which plugins must implement and API which core program provides for plugins.
Both are contracts. Both declares the way of communication.
And now, to most useful part. How the hell do plugins work?
By core I will mean program that loads up plugins
In the core we define interfaces that our plugins must implement - so, we could work with them and make some calls to it.
In the plugins, we get those interfaces (in case of C# - referenced corde DLL for example)
and implement them.
Now, when our core program is running and it knows it wants some specific plugin(because we said so, say, in configs)
It will search for it in order to load this.
In case of C# it would be DLL, I suppose. (yeah, actually, we can do whatever we want and use plugins written in another language and interpret/compile them after loading. Examples: lua.)
so, Core program finds and loads this DLL to it's memory. You got something like a handle to this DLL. So, via this handle you would ask to create an object of this type(your interface types from core) with this arguments for constructor.
And voila! You've got yourself an object from this dll.
You don't know what it is, but you know that it implements this interface
And you can work with it.
That's actually the point of interfaces.
 
Ben
Ok. I understand that (though you have described it in far more detail, which I can now completely understand).
 
In many cases we don't give a damn about what really object is. We care about that it object could do something that we need. - That "something" is declared in interface, that objects implements it and we're all happy without any knowledge abouc what this object really is.
@Ben Don't sweat it. Try to work with those things that you understand. If you have contradiction or a hole in your image of all of this - just ask me.
 
Ben
@RollingFeles Will do
 
This is a good tutorial (those that @Miniman provided)
no COM and just shows how to do what I described earlier.
 
Ben
So basically, We load a dll into our core program (using the plugin system that everyone is always raving about) so that we can pass it some information. From the core's perspective, it doesn't really now, nor really care what it does, just so long as it gets something back, that it understands.
 
6:55 AM
Yes. Almost like this. But core cares about what it does in some way. It doesn't care about specific - that's extension after all, but core knows what to call and what to make plugin do.
Also
there is no mythical plugin system
it's just simpliest and natural solution for compiled environments
 
Ben
@RollingFeles Then how does a plugin get loaded?
 
Deep down it's just your system API - it's just loads .DLL/.SO into the memory of your program.
It's not a plugin system it's a mechanism that predates plugins.
plugins can work just like that and use this solution.
As I said earlier, you can make plugins in different language and load them up differently.
 
Ben
@RollingFeles I think then what I'm referring to is a Class that simply provides a UI for a user to load a plugin.
 
That's just an implementation.
 
Ben
OK.
Do you mind if we pause here? Gotta head home
I'll be ~half hour?
 
6:59 AM
Nothing more. I can think of dozens more. With classes or not. In single or in different clases.
I don't mind.
 
Ben
OK. BBS
 
Ping me, but I may not answer immediately
 
 
2 hours later…
Ben
8:41 AM
Hey @RollingFeles. Sorry I took so long
 
Ben
Ok, so getting back into it - Can an API define the structure of the Plugin? E.g., COM C#?
As you and others have mentioned, that's the benefit of a plugin, but I just wanted to clarify
 
I think theoretical explanation is more or less complete. Tutorial should show how to do this in practical sense. If I understood correctly your task still is different.
What do you mean by structure?
 
Ben
Framework and language
 
Yes, of course.
 
Ben
8:49 AM
Like, the program I am developing this for, the SDK mentions that "VB.NET is no longer supported"
 
Well
It can mean a lot of things.
Context should clarify this
 
Ben
Which is part of my frustration - the support material is all in VB.NET, and my experience of the language is over 15 years old as well
I mean, yeah, sure saying something isn't supported doesn't necessarily mean that it won't work... just if it doesn't work, they're not going to do anything to help fix it
 
15 years and you're not familiar with interfaces?
I mean your solution is within .Net.
That's why you should study what they mean by "not supported",
 
Ben
Did programming in high-school, then did nothing until 5 years ago. Self-taught C#.
Either way, if it's supported or not, it's outside the scope of my goal. I know that they do support C#, which works out for me anyway
 
How dense/intense this experience? When you say 10 years programming in context of high-school it can mean different things. Including uni I have over 7 years of experience, but real professional experience is last 4 years and it tenfold greater in quantity and quality than uni experience :)
I think you should do good with C#.
syntax is a bit different but they are very close relatives with VB .Net due to the underlying platform.
> Which is part of my frustration
COM would be your real frustration :D
that's why whole chat started to point out way away from this :)
Okay. So, your task is to modify some GUI that somehow connected to plugin. Am I right?
 
Ben
8:58 AM
@RollingFeles High school. 3 Years total, then a 5-year hiatus
 
Ben
@RollingFeles Um, no.
 
I didn't get correctly what you meant by 15 years old experience. Sorry.
@Ben describe your task, please. Introduction into interfaces and plugins was necessary, but it may not bring you much closer to task completion.
 
Ben
The Core Program is a DMS that is able to extract meta-data from documents, and store them in a database. It makes management, searching, updating, and workflows much simpler because it just manages everything all in one place.
The plugin we want to develop does the same thing, just with a file type that is not supported within Adept already. Are you familiar with FLIR?
 
Nope
 
Ben
9:04 AM
FLIR is basically Thermal Imaging software. It is very powerful as it creates "Smart jpegs". Basically, it stores text within a jpg, that contains all of the information about the image - light levels, temperatures... etc.
 
I see.
 
Ben
You can also tag it with metadata, giving more information about the image itself. The area, the type of equipment and all that jazz. The only issue is that the files are taken with a camera, and saved as"001, 002, 003" which makes searching for relevant images difficult.
We have developed a program that reads the jpgs, searches for the relevant information, and extracts it, to be stored, currently in an excel spreadsheet.
This, however, needs to be translated into a plugin.
 
Well, then that introduction was more useful than I expected. I suggest to complete that tutorial that you linked earlier(@Miniman's)
There you should understand a bit clearer what to do and how to translate those VB.NET documentation to C#.
 
Ben
It works externally of course, but we want to implement it within the Core Program, so that it's "all in one place"
 
You've mentioned COM a lot. Do Adept use it for plugins?
And what Adept is? :)
 
Ben
9:09 AM
@RollingFeles From what I've seen, yes.
However, that doesn't mean it's restricted to COM
And just to clarify, COM is a framework... yes?
 
Weeeell.
COM is a solution.
Microsoft's solution to be precise.
 
Ben
As for Adept itself, I couldn't say. I've seen the API, which, from memory was in C#, but I couldn't say
...Ok?
"Solution" as in contains Projects and Classes? Or "Solution" to a "Problem"?
 
I can't call it just a framework. It has too many ties to Windows and building your solution based on COM/DCOM is much more than just referencing few libraries and using it.
@Ben latter.
 
Ben
Ah
 
My advice: Try to find a way without COM.
Consult your peers. Maybe they will help you to sort this out.
COM is not something horrible. But it will bog you down with many issues.
Many developers have love-hate relationship with COM.
It has it's huge pros, but cons sometimes hurt so much, that you can't ignore them and love COM.
 
Ben
9:16 AM
@RollingFeles So I've heard
The only thing is, even without COM, I'm not sure how it implements into the plugin structure. All I've seen is in reference to COM - COM classes, using Interfaces so that I can use COM, and so on.
 
@Ben first and foremost - finish that tutorial. Really, practice is needed to grasp how things are working.
 
Ben
OK. I'll have a go at it and see if I can get a better of everything :)
 
After that you should reserach target API. Maybe you will find more examples or understand more after this tutorial.
 
Ben
9:37 AM
@RollingFeles I'm already running into issues - I have received an error about my Form
 
Try to solve it. Read the error very carefully. If it doesn't tip into right direction - google the error. Chances are that you will find SO.se post with solution.
If nothing helps - I suggest to make a github/bitbucket repo, push your code there and show to me.
Or at least make a gist with the code where error is.
 
Ben
@RollingFeles Well, all I did is add the reference to the Plugin to the form
 
What is the Plugin and what is the form?
 
Ben
"Several partial classes in the same file"
@RollingFeles I am just following the tutorial right now, I haven't added anything else
 
@Ben the thing is that tutorial could be made on older .Net than you use now.
 
Ben
9:42 AM
Ah ok.
 
@Ben well... try to separate them.
Or you may try to switch target platform(i.e. .net version) in project properties to those what tutorial use
 
Ben
I figured it out - I had actually got two partial classes. I simply merged them and it solved the problem
 
actually, can't understand what the issue with several partial classes in one file. But nvm.
(it's my little rant to C# compiler)
 
Ben
public partial class TestPlugin : Form, IPlugin
 
@Ben that sounds like a solution. Just whatchout not to merge those things that shouldn't be merged.
 
Ben
10:35 AM
Ok, all done.
I have a basic understanding of how it works - the application calls the plugin, and aligns it with it's own, before running the plugin
I just don't understand the PluginAttribute class
Is that just something like a string or an int? But in this case, it's just used to identify it as the plugin dll?
 
11:02 AM
ah
it's used to find a class through reflection.
I've never used it. I've just searched type inheretid from plugin class interface.
I have my doubts about this approach, but it doesn't matter.
 
Ben
Ok
So, reflection is a common thing used in plugins..? Sort of a "check" to see if it is able to load?
 
No. Reflection is a tool to gather info about code during runtime.
hence reflection - realizing itself.
 
Ben
@RollingFeles Oh, right
 
I think type lookup would use reflection, yes.
 
Ben
Well, I at least have an understanding on the way it all fits together. The Interface Classes are what the API talks to.
 
11:09 AM
But I think it could be not the only way to do this.
 
Ben
No, hang on..
The Interfaces are what the application looks at, to line up the methods and properties. The plugin then knows what to do when the application calls it.
I.e. "ShowPlugin()"
The ShowPlugin method is something that the application does, with or without the plugin.
But now that the application has a plugin to do something else, when it calls Plugin.ShowMethod(), the Plugin has an interactive class that does the same thing
So the Interfaces are like a copy of the "Document" (referring back to the earlier analogy you provided). It then takes that information, does what it does with it, then returns a copy of that "Document", with the new information.
Right?
 
11:33 AM
Nope. Interface is just a description of a functionalities (collection of signatures/properties). That's all. Core know what and how to call from plugin, because it found some class from loaded dll which implements Interface it knows.
 
 
12 hours later…
Ben
11:14 PM
Hi @RollingFeles, I realised that I forgot something. The plugins that this program use have GUIDs to identify the plugin, rather than using techniques like reflection, etc.
I believe that is the reason for the COM structure; though I am unsure if that this is restricted to COM. I have asked them to specify the need for COM, and am waiting on a response
 
Ben
11:52 PM
Though it doesn't look like I'll be getting a response today...
 

  last day (15 days later) »